Logger

Author:
Armin Trattnig
Version:
1.0
Includes:
<stdlib.h>
<stdio.h>
<stdarg.h>

Introduction

Logger provides basic logging mechanisms. The desired loglevel and output can be set.

Updated:
Wednesday, September 10, 2014


Functions

logMsg

logMsg


extern void logMsg (
    int logLvl,
    const char *format,
    ... );  
Parameters
logLvl

Loglevel for the message, use the defined Loglevels

format

Message, working exactly like printf(format, ...)

Discussion

Writes a log message to logOutput with the desired loglevel

WARNING:

Global variables logLevel and logOutput must be initialized before calling logMsg


Globals

logLevel
logOutput

logLevel


extern int logLevel;  
Discussion

Global variable logLevel. Can be set anywhere in the program. Represents the current log level.


logOutput


extern FILE *logOutput;  
Discussion

Global variable logOutput. Can be set anywhere in the program. File pointer to the output of the log messages.


Macro Definitions

LOGLEVEL_DEBUG

Loglevels determine the amount of log created by the software

LOGLEVEL_ERROR

Loglevels determine the amount of log created by the software

LOGLEVEL_INFO

Loglevels determine the amount of log created by the software

LOGLEVEL_OFF

Loglevels determine the amount of log created by the software

LOGLEVEL_TRACE

Loglevels determine the amount of log created by the software

LOGLEVEL_WARNING

Loglevels determine the amount of log created by the software

Loglevels supported by Logger

Loglevels determine the amount of log created by the software


LOGLEVEL_DEBUG


Loglevels determine the amount of log created by the software

#define LOGLEVEL_DEBUG 4 
Discussion

More detailed description of what is happening

See Also


LOGLEVEL_ERROR


Loglevels determine the amount of log created by the software

#define LOGLEVEL_ERROR 1 
Discussion

Errors, which are critcal to program execution will be logged

See Also


LOGLEVEL_INFO


Loglevels determine the amount of log created by the software

#define LOGLEVEL_INFO 3 
Discussion

Messages, which provide general information about what is going on

See Also


LOGLEVEL_OFF


Loglevels determine the amount of log created by the software

#define LOGLEVEL_OFF 0 
Discussion

Logging is completely disabled

See Also


LOGLEVEL_TRACE


Loglevels determine the amount of log created by the software

#define LOGLEVEL_TRACE 5 
Discussion

Extremely detailed description of what is happening

See Also


LOGLEVEL_WARNING


Loglevels determine the amount of log created by the software

#define LOGLEVEL_WARNING 2 
Discussion

Warning messages are logged, which inform the user of unexpected results

See Also


Loglevels supported by Logger


Loglevels determine the amount of log created by the software

#define LOGLEVEL_OFF 0 
#define LOGLEVEL_ERROR 1 
#define LOGLEVEL_WARNING 2 
#define LOGLEVEL_INFO 3 
#define LOGLEVEL_DEBUG 4 
#define LOGLEVEL_TRACE 5 
Included Defines
LOGLEVEL_OFF

Logging is completely disabled

LOGLEVEL_ERROR

Errors, which are critcal to program execution will be logged

LOGLEVEL_WARNING

Warning messages are logged, which inform the user of unexpected results

LOGLEVEL_INFO

Messages, which provide general information about what is going on

LOGLEVEL_DEBUG

More detailed description of what is happening

LOGLEVEL_TRACE

Extremely detailed description of what is happening

Discussion

All messages will be logged with logLvl < logLevel

See Also