34 #include "ptlib_config.h"
40 class PSystemLogTarget;
47 class PSystemLog :
public PObject,
public std::ostream
70 Level level = NumLogLevels
74 ~PSystemLog() { flush(); }
81 static PSystemLogTarget & GetTarget();
85 static void SetTarget(
86 PSystemLogTarget * target,
87 bool autoDelete =
true
91 static void OutputToTarget(
92 PSystemLog::Level level,
98 PSystemLog(
const PSystemLog & other);
99 PSystemLog & operator=(
const PSystemLog &);
101 class Buffer :
public streambuf {
104 virtual int_type overflow(int_type=EOF);
105 virtual int_type underflow();
114 friend class PSystemLogTarget;
118 class PSystemLogTarget :
public PObject
132 void SetThresholdLevel(
133 PSystemLog::Level level
134 ) { m_thresholdLevel = level; }
141 PSystemLog::Level GetThresholdLevel()
const {
return m_thresholdLevel; }
145 void SetOutputLevelName(
147 ) { m_outputLevelName = flag; }
151 bool GetOutputLevelName()
const {
return m_outputLevelName; }
160 PSystemLog::Level level,
168 PSystemLog::Level level,
176 bool m_outputLevelName;
179 PSystemLogTarget(
const PSystemLogTarget & other);
180 PSystemLogTarget & operator=(
const PSystemLogTarget &);
182 friend void PSystemLog::OutputToTarget(PSystemLog::Level level,
const char * msg);
188 class PSystemLogToNowhere :
public PSystemLogTarget
190 PCLASSINFO(PSystemLogToNowhere, PSystemLogTarget);
192 virtual void Output(PSystemLog::Level,
const char *)
200 class PSystemLogToStderr :
public PSystemLogTarget
202 PCLASSINFO(PSystemLogToStderr, PSystemLogTarget);
209 PSystemLog::Level level,
219 class PSystemLogToTrace :
public PSystemLogTarget
221 PCLASSINFO(PSystemLogToTrace, PSystemLogTarget);
233 PSystemLog::Level level,
243 class PSystemLogToFile :
public PSystemLogTarget
245 PCLASSINFO(PSystemLogToFile, PSystemLogTarget);
259 PSystemLog::Level level,
268 const PFilePath & GetFilePath()
const {
return m_file.GetFilePath(); }
280 const PString & timestamp = DefaultTimestamp()
281 ) :
PFile::RotateInfo(dir, prefix, suffix, timestamp, 0) { }
282 virtual void OnCloseFile(
PFile & file,
const PFilePath & rotatedTo);
283 virtual bool OnOpenFile(
PFile & file);
284 virtual void OnMessage(
bool error,
const PString & msg);
289 virtual void SetRotateInfo(
290 const RotateInfo & info,
296 const RotateInfo & GetRotateInfo()
const {
return m_rotateInfo; }
312 RotateInfo m_rotateInfo;
320 class PSystemLogToNetwork :
public PSystemLogTarget
322 PCLASSINFO(PSystemLogToNetwork, PSystemLogTarget);
324 enum { RFC3164_Port = 514 };
330 WORD port = RFC3164_Port,
331 unsigned facility = 16
335 WORD port = RFC3164_Port,
336 unsigned facility = 16
345 PSystemLog::Level level,
362 class PSystemLogToDebug :
public PSystemLogTarget
364 PCLASSINFO(PSystemLogToDebug, PSystemLogTarget);
371 PSystemLog::Level level,
376 #elif !defined(P_VXWORKS)
377 #define P_SYSTEMLOG_TO_SYSLOG 1
380 class PSystemLogToSyslog :
public PSystemLogTarget
382 PCLASSINFO(PSystemLogToSyslog, PSystemLogTarget);
387 const char * ident = NULL,
394 ~PSystemLogToSyslog();
402 PSystemLog::Level level,
418 #define PSYSTEMLOG(level, variables) \
419 if (PSystemLog::GetTarget().GetThresholdLevel() >= PSystemLog::level) { \
420 PSystemLog P_systemlog(PSystemLog::level); \
421 P_systemlog << variables; \
422 P_systemlog.width(-12345678); \
This class represents a disk file.
Definition: file.h:57
Array of characters.
Definition: array.h:552
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:2164
Local Time.
Definition: ptime.h:65
A socket channel that uses the UDP transport on the Internet Protocol.
Definition: udpsock.h:42
Information on how to rotate files.
Definition: file.h:587
This class describes a full description for a file on the particular platform.
Definition: filepath.h:61
A class describing an IP address and port number combination.
Definition: ipsock.h:278
Class to represent a directory in the operating system file system.
Definition: pdirect.h:173
The character string class.
Definition: pstring.h:108
This class defines a thread mutual exclusion object.
Definition: mutex.h:101
static const PString & Empty()
Return an empty string.
A class describing an IP address.
Definition: ipsock.h:59
#define P_DECLARE_ENUM_EX(name, countName, firstName, firstValue,...)
This declares a standard enumeration (enum) of symbols with ++ and – operators.
Definition: object.h:229
A class representing a a structured file that is portable accross CPU architectures.
Definition: textfile.h:45
Ultimate parent class for all objects in the class library.
Definition: object.h:2204