42 #ifndef _DWMFILELOGGER_HH_ 43 #define _DWMFILELOGGER_HH_ 78 e_notBuffered = _IONBF,
79 e_lineBuffered = _IOLBF,
80 e_blockBuffered = _IOFBF
83 static const uint32_t k_defaultRolloverSize = 100 * 1024;
84 static const uint32_t k_defaultNumRolloverFiles = 1;
108 bool Open(
const std::string & ident,
int logopt,
109 const std::string & filename,
110 BufferingType bufferingType = e_blockBuffered);
127 bool Log(
int priority,
const char * message, ...);
134 bool Log(
const std::string & filename,
int lineno,
135 const std::string &
function,
int priority,
136 const char * message, ...);
142 bool VaLog(
int priority,
const std::string & message,
151 bool VaLog(
const std::string & filename,
int lineno,
152 const std::string &
function,
int priority,
153 const std::string & message, va_list & vaList);
248 bool SetPriorities(
const std::map<
int, std::pair<std::string,std::string> > & priorities);
259 int _minimumPriority;
261 bool _showPriorities;
263 bool _showFileLocation;
264 std::string _hostName;
265 std::string _filePrefix;
268 uint32_t _numRolloverFiles;
269 off_t _currentFilePosition;
270 BufferingType _bufferingType;
271 std::map<int,std::string> _priorityTags;
272 std::map<std::string,int> _priorityNames;
273 mutable std::mutex _mutex;
278 bool OpenNoLock(
const std::string & ident,
int logopt,
279 const std::string & filename,
280 BufferingType bufferingType = e_blockBuffered);
281 bool OpenFile(
const std::string & filename);
282 bool RollFilesOver();
283 void InitializePriorities();
288 #endif // _DWMFILELOGGER_HH_ int MinimumPriority() const
Returns the lowest message priority that the logger will log.
bool SetPriorities(const std::map< int, std::pair< std::string, std::string > > &priorities)
Overrides the standard priority tags and names.
bool ShowFunction() const
If the logger is set to show function information in Log(const string &, int, const string &...
bool Log(int priority, const char *message,...)
Just like syslog(), takes a priority and a format string and variable list of arguments.
bool IsOpen() const
Returns true if the logger is open, else returns false.
uint32_t NumRolloverFiles() const
Returns the number of rollover files used by the logger.
bool VaLog(int priority, const std::string &message, va_list &vaList)
Just like vsyslog(), takes a priority and a format string and a va_list.
Definition: DwmBZ2IO.hh:67
bool ShowFileLocation() const
If the logger is set to show file location information, returns true.
This class encapsulates syslog-like logging, but uses files instead of the syslog facility...
Definition: DwmFileLogger.hh:74
uint32_t RolloverSize() const
Returns the current rollover size used by the logger.
bool Flush()
Writes buffered data to the output log (i.e.
~FileLogger()
Destructor. Closes the log if it's open.
bool Open(const std::string &ident, int logopt, const std::string &filename, BufferingType bufferingType=e_blockBuffered)
Opens the logger.
bool Close()
Closes the logger.
bool ShowPriorities() const
If the logger is set to show priorities in each log message, returns true.
std::string PriorityTag(int priority)
Returns the priority tag ("[F]", "[W]", et.