54 std::string logPath = EVEMU_ROOT
"/logs/";
66 logPath = EVEMU_ROOT
"/logs/";
76 Debug(
"Log",
"Log system shutting down" );
84 Blue(
" Log System",
"Log System Initialized.");
92 logPath = EVEMU_ROOT
"/logs/";
209 if( NULL != filename )
211 file = fopen( filename,
"w" );
240 Print(
" %c ", pfx );
242 if( source && *source )
245 Print(
"%s: ", source );
266 Print(
"%02u:%02u:%02u", t.tm_hour, t.tm_min, t.tm_sec );
308 #ifdef HAVE_WINDOWS_H
309 ::SetConsoleTextAttribute( mStdOutHandle,
COLOR_TABLE[ color ] );
326 char filename[ FILENAME_MAX + 1 ];
327 std::string logFile = logPath +
"%02u-%02u-%04u-%02u-%02u.log";
328 snprintf( filename, FILENAME_MAX + 1, logFile.c_str(),
329 t.tm_mday, t.tm_mon + 1, t.tm_year + 1900, t.tm_hour, t.tm_min );
335 Warning(
"Log",
"Unable to open logfile '%s': %s", filename, strerror( errno ) );
void PrintTime()
Prints current time.
void SetColor(Color color)
Sets the color of the output text.
tm * localtime_r(const time_t *timep, tm *result)
void Cyan(const char *source, const char *fmt,...)
Logs a message to console in cyan.
A lock for a Lockable object.
void Blue(const char *source, const char *fmt,...)
Logs a message to console in blue.
void Debug(const char *source, const char *fmt,...)
Logs a debug message to file and console.
void Yellow(const char *source, const char *fmt,...)
Logs a message to console in yellow.
Mutex mMutex
Protection against concurrent log messages.
FILE * mLogfile
The active logfile.
void Magenta(const char *source, const char *fmt,...)
Logs a message to console in magenta.
void SetLogfileDefault(std::string logPath)
Sets the default logfile.
void Log(const char *source, const char *fmt,...)
Logs a message to file.
static const char *const COLOR_TABLE[COLOR_COUNT]
Color translation table.
#define is_log_enabled(type)
time_t mTime
Current timestamp.
bool SetLogfile(const char *filename)
Sets the logfile to be used.
void SetTime(time_t time)
Sets the log system time every main loop.
void Warning(const char *source, const char *fmt,...)
Logs a warning message to file.
Color
A convenience color enum.
void InitializeLogging(std::string logPath)
Initializes and sets the Log file path.
NewLog()
Primary constructor, initializes logging.
~NewLog()
Destructor, closes the logfile.
void Green(const char *source, const char *fmt,...)
Logs a message to console in green.
void PrintVa(const char *fmt, va_list ap)
Prints a raw message.
void White(const char *source, const char *fmt,...)
Logs a message to console in white.
void PrintMsg(Color color, char pfx, const char *source, const char *fmt, va_list ap)
Prints a message.
void Error(const char *source, const char *fmt,...)
Logs error message to console and file.
void Print(const char *fmt,...)
Prints a raw message.