21 #ifndef G_LOG_OUTPUT_H
22 #define G_LOG_OUTPUT_H
45 enum SyslogFacility { User ,
Daemon , Mail , Cron } ;
47 LogOutput(
const std::string & prefix ,
bool output ,
bool summary_logging ,
48 bool verbose_logging ,
bool with_debug ,
bool with_level ,
49 bool with_timestamp ,
bool strip_context ,
bool use_syslog ,
50 const std::string & stderr_replacement = std::string() ,
51 SyslogFacility syslog_facility = User ) ;
64 explicit LogOutput(
bool output_with_logging ,
bool verbose_and_debug =
true ,
65 const std::string & stderr_replacement = std::string() ) ;
72 virtual void rawOutput( std::ostream & , G::Log::Severity ,
const std::string & ) ;
80 bool enable(
bool enabled =
true ) ;
83 void quiet(
bool quiet_stderr =
true ) ;
88 void verbose(
bool verbose_log =
true ) ;
91 bool at( G::Log::Severity )
const ;
94 bool at( G::Log::Severity ,
const std::string & group )
const ;
98 static void groups(
const std::string & ) ;
108 static void output( G::Log::Severity ,
const char * file ,
int line ,
const std::string & ) ;
112 static void assertion(
const char * file ,
int line ,
bool test ,
const char * ) ;
121 static void register_(
const std::string & exe ) ;
128 typedef size_t size_type ;
133 void appendTimestampStringTo( std::string & ) ;
134 static std::string dateString() ;
135 void doOutput( G::Log::Severity ,
const std::string & ) ;
136 void doOutput( G::Log::Severity s ,
const char * ,
int ,
const std::string & ) ;
137 void doAssertion(
const char * ,
int ,
const std::string & ) ;
138 static const char * levelString( Log::Severity s ) ;
139 static std::string itoa(
int ) ;
140 static std::string fileAndLine(
const char * ,
int ) ;
143 static std::ostream & err(
const std::string & ) ;
144 static void getLocalTime( time_t ,
struct std::tm * ) ;
147 std::string m_prefix ;
156 std::set<std::string> m_groups ;
157 std::ostream & m_std_err ;
158 SyslogFacility m_facility ;
160 std::vector<char> m_time_buffer ;
164 std::string m_buffer ;
void quiet(bool quiet_stderr=true)
Enables or disables quiet-stderr mode, intended for daemons that log to syslog and only want startup ...
LogOutput(const std::string &prefix, bool output, bool summary_logging, bool 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.
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.
virtual void onAssert()
Called during an assertion failure.
virtual void rawOutput(std::ostream &, G::Log::Severity, const std::string &)
Overridable.
static void groups(const std::string &)
Sets the list of active logging groups.
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.
static void register_(const std::string &exe)
Registers the given executable as a source of logging.
bool at(G::Log::Severity) const
Returns true if logging should occur for 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.