MtnLog
2.7.2
Moltony's Logging Library
|
#include <stdbool.h>
#include <stdarg.h>
Go to the source code of this file.
Macros | |
#define | MTNLOG_BOOL bool |
MtnLog boolean type. More... | |
#define | mtnlogMessageC(level, ...) mtnlogMessageCInternal(__LINE__, __FILE__, "", (level), __VA_ARGS__) |
Log message with context. More... | |
#define | mtnlogMessageTagC(level, tag, ...) mtnlogMessageTagCInternal(__LINE__, __FILE__, "", (level), (tag), __VA_ARGS__) |
Log message with tag and context. More... | |
Typedefs | |
typedef void(* | MtnLogCallback) (MtnLogLevel, const char *, const char *) |
Log callback function. More... | |
Enumerations | |
enum | MtnLogLevel { MTNLOG_INFO = 0 , MTNLOG_WARNING = 1 , MTNLOG_ERROR = 2 } |
Enum representing logging level. More... | |
Functions | |
void | mtnlogInit (const MtnLogLevel level, const char *logFileName) |
Initialize logging. More... | |
void | mtnlogColor (const MTNLOG_BOOL enable) |
Enable or disable color for messages. More... | |
MTNLOG_BOOL | mtnlogCheckColor (void) |
Check if color is supported. More... | |
void | mtnlogConsoleOutput (const MTNLOG_BOOL enable) |
Enable or disable outputting log messages into console (stdout) More... | |
void | mtnlogFileOutput (const MTNLOG_BOOL enable) |
Enable or disable outputting log messages into the log file. More... | |
void | mtnlogSetLevel (const MtnLogLevel level) |
Set logging level. More... | |
void | mtnlogSetCallback (const MtnLogCallback cb) |
Set log callback. More... | |
void | mtnlogTimestamps (const MTNLOG_BOOL enable) |
Enable or disable log timestamps. More... | |
void | mtnlogConsoleTimestamps (const MTNLOG_BOOL enable) |
Enable or disable putting timestamps in console. More... | |
void | mtnlogMessage (const MtnLogLevel level, const char *format,...) |
Print a message to the log. More... | |
void | mtnlogVMessage (const MtnLogLevel level, const char *format, va_list l) |
Print a message to the log (VA list version) More... | |
void | mtnlogMessageTag (const MtnLogLevel level, const char *tag, const char *format,...) |
Print a message to the log with a tag. More... | |
void | mtnlogVMessageTag (const MtnLogLevel level, const char *tag, const char *format, va_list l) |
Print a message to the log with a tag (VA list version) More... | |
void | mtnlogMessageCInternal (const int line, const char *file, const char *function, const MtnLogLevel level, const char *message,...) |
Internal function for mtnlogMessageC. More... | |
void | mtnlogMessageTagCInternal (const int line, const char *file, const char *function, const MtnLogLevel level, const char *tag, const char *message,...) |
Internal function for mtnlogMessageTagC. More... | |
#define MTNLOG_BOOL bool |
MtnLog boolean type.
#define mtnlogMessageC | ( | level, | |
... | |||
) | mtnlogMessageCInternal(__LINE__, __FILE__, "", (level), __VA_ARGS__) |
Log message with context.
level | level of the message |
... | variadic arguments including the format string |
#define mtnlogMessageTagC | ( | level, | |
tag, | |||
... | |||
) | mtnlogMessageTagCInternal(__LINE__, __FILE__, "", (level), (tag), __VA_ARGS__) |
Log message with tag and context.
level | level of the message |
tag | message tag |
... | variadic arguments including the format string |
typedef void(* MtnLogCallback) (MtnLogLevel, const char *, const char *) |
Log callback function.
Parameter 1: Log level
Parameter 2: Timestamp
Parameter 3: Message
enum MtnLogLevel |
MTNLOG_BOOL mtnlogCheckColor | ( | void | ) |
Check if color is supported.
On Windows this always returns true
.
On non-Windows platforms this checks the TERM
environment variable.
void mtnlogColor | ( | const MTNLOG_BOOL | enable | ) |
Enable or disable color for messages.
enable | enable or disable color |
Color is only supported for platforms that support ANSI escape sequences for colors. This will not change the log file, only console output.
void mtnlogConsoleOutput | ( | const MTNLOG_BOOL | enable | ) |
Enable or disable outputting log messages into console (stdout)
enable | enable or disable console output |
void mtnlogConsoleTimestamps | ( | const MTNLOG_BOOL | enable | ) |
Enable or disable putting timestamps in console.
enable | enable or disable |
void mtnlogFileOutput | ( | const MTNLOG_BOOL | enable | ) |
Enable or disable outputting log messages into the log file.
enable | Enable ot disable file output |
This can be useful if you're working in an environment without a file system or want to only have a log in the console.
void mtnlogInit | ( | const MtnLogLevel | level, |
const char * | logFileName | ||
) |
Initialize logging.
level | logging level |
logFileName | name of the log file |
void mtnlogMessage | ( | const MtnLogLevel | level, |
const char * | format, | ||
... | |||
) |
Print a message to the log.
level | level of the message |
format | formatting string |
Used the same way as printf
.
void mtnlogMessageCInternal | ( | const int | line, |
const char * | file, | ||
const char * | function, | ||
const MtnLogLevel | level, | ||
const char * | message, | ||
... | |||
) |
Internal function for mtnlogMessageC.
void mtnlogMessageTag | ( | const MtnLogLevel | level, |
const char * | tag, | ||
const char * | format, | ||
... | |||
) |
Print a message to the log with a tag.
level | level of the message |
tag | message tag |
format | formatting string |
void mtnlogMessageTagCInternal | ( | const int | line, |
const char * | file, | ||
const char * | function, | ||
const MtnLogLevel | level, | ||
const char * | tag, | ||
const char * | message, | ||
... | |||
) |
Internal function for mtnlogMessageTagC.
void mtnlogSetCallback | ( | const MtnLogCallback | cb | ) |
Set log callback.
cb | callback |
void mtnlogSetLevel | ( | const MtnLogLevel | level | ) |
Set logging level.
level | level |
void mtnlogTimestamps | ( | const MTNLOG_BOOL | enable | ) |
Enable or disable log timestamps.
enable | enable or disable |
void mtnlogVMessage | ( | const MtnLogLevel | level, |
const char * | format, | ||
va_list | l | ||
) |
Print a message to the log (VA list version)
level | level of the message |
format | formatting string |
l | VA list to be used |
void mtnlogVMessageTag | ( | const MtnLogLevel | level, |
const char * | tag, | ||
const char * | format, | ||
va_list | l | ||
) |
Print a message to the log with a tag (VA list version)
level | level of the message |
tag | message tag |
format | formatting string |
l | VA list to be used |