The qDecoder Project

qLog.c File Reference

Rotating File Logger API. More...


Functions

Q_LOGqLogOpen (const char *logbase, const char *filenameformat, int rotateinterval, bool flush)
 Open ratating-log file.
bool qLogClose (Q_LOG *log)
 Close ratating-log file.
bool qLogSetConsole (Q_LOG *log, bool consoleout)
 Set screen out.
bool qLogFlush (Q_LOG *log)
 Flush buffered log.
bool qLog (Q_LOG *log, const char *format,...)
 Log messages.


Detailed Description

Rotating File Logger API.


Function Documentation

Q_LOG* qLogOpen ( const char *  logbase,
const char *  filenameformat,
int  rotateinterval,
bool  flush 
)

Open ratating-log file.

Parameters:
logbase log directory
filenameformat filename format. formatting argument is same as strftime()
rotateinterval rotating interval seconds
flush set to true if you want to flush everytime logging. false for buffered logging
Returns:
a pointer of Q_LOG structure
Note:
rotateinterval is not relative time. If you set it to 3600, log file will be rotated at every hour. And filenameformat is same as strftime(). So If you want to log with hourly rotating, filenameformat must be defined at least hourly format, such like "xxx-%Y%m%d%H.log". You can set it to "xxx-%H.log" for daily overwriting.
   Q_LOG *log = qLogOpen("/tmp", "qdecoder-%Y%m%d.err", 86400, false);
   qLogClose(log);

bool qLogClose ( Q_LOG log  ) 

Close ratating-log file.

Parameters:
log a pointer of Q_LOG
Returns:
true if successful, otherewise returns false

bool qLogSetConsole ( Q_LOG log,
bool  consoleout 
)

Set screen out.

Parameters:
log a pointer of Q_LOG
consoleout if set it to true, logging messages will be printed out into stderr
Returns:
true if successful, otherewise returns false

bool qLogFlush ( Q_LOG log  ) 

Flush buffered log.

Parameters:
log a pointer of Q_LOG
Returns:
true if successful, otherewise returns false

bool qLog ( Q_LOG log,
const char *  format,
  ... 
)

Log messages.

Parameters:
log a pointer of Q_LOG
format messages format
Returns:
true if successful, otherewise returns false


[Home] [About] [Examples] [Changes] [Download] [SVN Repository] [Install] [Reference]