Design Pattern Examples
Overview of object-oriented design patterns
Bridge_LogHelper.c File Reference

Implementation of the LogHelper_FormatLogLine() function, used in the Bridge Pattern. More...

#include "Bridge_LogHelper.h"
#include <stdlib.h>
#include <stdio.h>
#include "helpers/datetime.h"
#include "helpers/makelocaltime.h"
Include dependency graph for Bridge_LogHelper.c:

Go to the source code of this file.

Functions

static const char * _GetTimeStamp (void)
 Return a regular time stamp of the current time in local time.
 
bool LogHelper_FormatLogLine (const char *loglevel, const char *message, char *output, size_t maxOutputSize)
 Format a line for logging, including time stamp.
 

Detailed Description

Implementation of the LogHelper_FormatLogLine() function, used in the Bridge Pattern.

Definition in file Bridge_LogHelper.c.

Function Documentation

◆ _GetTimeStamp()

static const char * _GetTimeStamp ( void  )
static

Return a regular time stamp of the current time in local time.

Returns
A string containing the current date and time expressed in local time. Valid until the next call to this function.

Definition at line 19 of file Bridge_LogHelper.c.

References datetime_now(), and datetime_to_string().

Referenced by DesignPatternExamples_cpp::LoggerHelpers::FormatLogLine(), and LogHelper_FormatLogLine().

◆ LogHelper_FormatLogLine()

bool LogHelper_FormatLogLine ( const char *  loglevel,
const char *  message,
char *  output,
size_t  maxOutputSize 
)

Format a line for logging, including time stamp.

Parameters
loglevelLevel of logging (TRACE, INFO, ERROR)
messageMessage to log
outputBuffer to fill with the formatted log line.
maxOutputSizeMaximum size of output buffer in characters.
Returns
Returns true if the log was formatted into the buffer; otherwise, returns false.

Definition at line 29 of file Bridge_LogHelper.c.

References _GetTimeStamp().

Referenced by _WriteLine().