8 #ifndef BOOSTER_LOGGER_H 9 #define BOOSTER_LOGGER_H 11 #include <booster/config.h> 13 #include <booster/auto_ptr_inc.h> 15 #include <booster/copy_ptr.h> 16 #include <booster/hold_ptr.h> 17 #include <booster/noncopyable.h> 83 char const *module()
const;
87 char const *file_name()
const;
91 int file_line()
const;
95 std::string log_message()
const;
104 char const *file_name_;
107 std::auto_ptr<std::ostringstream> message_;
126 virtual void log(
message const &m) = 0;
142 static logger &instance();
149 bool should_be_logged(
level_type level,
char const *module);
158 void set_log_level(
level_type level,
char const *module);
163 void reset_log_level(
char const *module);
186 void remove_all_sinks();
197 static char const *level_to_string(
level_type level);
201 static level_type string_to_level(std::string
const &);
210 static const int max_entries_size_ = 1024;
212 entry entries_[max_entries_size_];
249 virtual void log(
message const &);
271 virtual void log(
message const &msg);
290 static const int app = -1;
303 file(std::string
const &file_name,
int max_files = 0);
310 void open(std::string file_name);
317 void max_files(
unsigned limit);
331 void set_timezone(std::string
const &name);
334 virtual void log(
message const &);
337 void shift(std::string
const &base);
338 std::string format_file(std::string
const &,
int);
341 BOOSTER_UNUSED_MEMBER
size_t max_size_;
342 BOOSTER_UNUSED_MEMBER
size_t current_size_;
345 bool use_local_time_;
353 class BOOSTER_API syslog :
public sink {
369 syslog(std::string
const &
id,
int opts,
int facility = 0);
373 syslog(
int opts,
int facility = 0);
377 virtual void log(
message const &);
408 #define BOOSTER_LOG(level,module) \ 409 ::booster::log::logger::instance().should_be_logged(::booster::log::level,module) \ 410 && ::booster::log::message(::booster::log::level,module,__FILE__,__LINE__).out() 414 #define BOOSTER_EMERG(m) BOOSTER_LOG(emergency,m) 415 #define BOOSTER_ALERT(m) BOOSTER_LOG(alert,m) 417 #define BOOSTER_CRITICAL(m) BOOSTER_LOG(critical,m) 419 #define BOOSTER_ERROR(m) BOOSTER_LOG(error,m) 421 #define BOOSTER_WARNING(m) BOOSTER_LOG(warning,m) 423 #define BOOSTER_NOTICE(m) BOOSTER_LOG(notice,m) 425 #define BOOSTER_INFO(m) BOOSTER_LOG(info,m) 427 #define BOOSTER_DEBUG(m) BOOSTER_LOG(debug,m) This is the abstract interface to general sink - the consumer of the logged messages.
Definition: log.h:117
log file based sink - sends messages to log file
Definition: log.h:282
This is the central class that manages all logging operations.
Definition: log.h:137
BOOSTER_API std::string format_plain_text_message(message const &msg)
stderr based sink - sends messages to standard error output
Definition: log.h:246
BOOSTER_API std::string format_plain_text_message_tz(message const &msg, int timezone_offset=0)
log sink for a generic std::ostream
Definition: log.h:262
This class represents a single message that should be written to log.
Definition: log.h:57
level_type
Definition: log.h:38
basic_message< char > message
Definition: message.h:494
Booster library namespace. The library that implements Boost Like API in ABI backward compatible way...
Definition: application.h:23
This class makes impossible to copy any class derived from this one.
Definition: noncopyable.h:15