12#include "helpers/formatstring.h"
32 if (logger != NULL && loggerType != NULL)
34 char *buffer =
formatstring(
"Starting log to %s example", loggerType);
38 logger->
LogInfo(
"An example of an informational line", logger->
data);
39 logger->
LogError(
"An example of an error log entry", logger->
data);
43 buffer =
formatstring(
"Done with log to %s example", loggerType);
70 printf(
"\nBridge_Exercise\n");
74 if (fileLogger != NULL)
76 printf(
" Example of writing to a log file...\n");
82 printf(
" Error! Failed to create a file logger\n");
88 if (consoleLogger != NULL)
90 printf(
" Example of writing to the console...\n");
96 printf(
" Error! Failed to create a console logger\n");
102 if (nullLogger != NULL)
104 printf(
" Example of writing to a Null object (no output)...\n");
110 printf(
" Error! Failed to create a console logger\n");
void Bridge_Exercise(void)
Example of using the Bridge Pattern.
static void _Bridge_Exercise_Demonstrate_Logging(ILogger *logger, const char *loggerType)
Helper function to show an example of writing to a logger.
ILogger * CreateLogger(LoggerTypes loggerType, const char *filename)
Return an interface for the specified logger.
void DestroyLogger(ILogger *logger)
Release any resources associated with the given logger. The given ILogger instance is no longer valid...
Declaration of the ILogger interface, along with the CreateLogger() and DestroyLogger() functions use...
@ LoggerType_ToFile
Log to a file. One additional parameter: the name of the file to log to.
@ LoggerType_ToNull
Log to nowhere, that is, throw out all logging. No additional parameters.
@ LoggerType_ToConsole
Log to the console. No additional parameters.
Declaration of the Bridge_Exercise() function as used in the Bridge Pattern.
void(* LogError)(const char *message, void *data)
Log error messages to the configured output.
void * data
Data associated with a specific instance of a logger.
void(* LogInfo)(const char *message, void *data)
Log informational messages to the configured output.
void(* LogTrace)(const char *message, void *data)