21 #ifndef G_LOG_OUTPUT_H
22 #define G_LOG_OUTPUT_H
44 enum SyslogFacility { User ,
Daemon , Mail , Cron } ;
46 LogOutput(
const std::string & prefix ,
bool output ,
bool with_logging ,
47 bool with_verbose_logging ,
bool with_debug ,
bool with_level ,
48 bool with_timestamp ,
bool strip_context ,
bool use_syslog ,
49 const std::string & stderr_replacement = std::string() ,
50 SyslogFacility syslog_facility = User ) ;
63 explicit LogOutput(
bool output_with_logging ,
bool verbose_and_debug =
true ,
64 const std::string & stderr_replacement = std::string() ) ;
71 virtual void rawOutput( std::ostream & , G::Log::Severity ,
const std::string & ) ;
79 bool enable(
bool enabled =
true ) ;
82 void verbose(
bool verbose_log =
true ) ;
85 bool at( G::Log::Severity )
const ;
91 static void output( G::Log::Severity ,
const char * file ,
int line ,
const std::string & ) ;
95 static void assertion(
const char * file ,
int line ,
bool test ,
const char * ) ;
105 typedef size_t size_type ;
110 void appendTimestampStringTo( std::string & ) ;
111 static std::string dateString() ;
112 void doOutput( G::Log::Severity ,
const std::string & ) ;
113 void doOutput( G::Log::Severity s ,
const char * ,
int ,
const std::string & ) ;
114 void doAssertion(
const char * ,
int ,
const std::string & ) ;
115 static const char * levelString( Log::Severity s ) ;
116 static std::string itoa(
int ) ;
117 static std::string fileAndLine(
const char * ,
int ) ;
120 static std::ostream & err(
const std::string & ) ;
121 static void getLocalTime( time_t ,
struct std::tm * ) ;
124 std::string m_prefix ;
132 std::ostream & m_std_err ;
133 SyslogFacility m_facility ;
135 std::vector<char> m_time_buffer ;
bool syslog() const
Returns true if syslog output is enabled.
bool enable(bool enabled=true)
Enables or disables output. Returns the previous setting.
static LogOutput * instance()
Returns a pointer to the controlling LogOutput object.
A static interface for daemonising the calling process.
LogOutput(const std::string &prefix, bool output, bool with_logging, bool with_verbose_logging, bool with_debug, bool with_level, bool with_timestamp, bool strip_context, bool use_syslog, const std::string &stderr_replacement=std::string(), SyslogFacility syslog_facility=User)
Constructor.
virtual void onAssert()
Called during an assertion failure.
virtual void rawOutput(std::ostream &, G::Log::Severity, const std::string &)
Overridable.
virtual ~LogOutput()
Destructor.
static void assertion(const char *file, int line, bool test, const char *)
Makes an assertion check (regardless of any LogOutput object).
static void output(G::Log::Severity, const char *file, int line, const std::string &)
Generates output if there is an existing LogOutput object which is enabled.
bool at(G::Log::Severity) const
Returns true if output() generates output at the given severity level.
Controls and implements low-level logging output, as used by the Log interface.
void verbose(bool verbose_log=true)
Enables or disables verbose logging.