8 #ifndef BOOSTER_LOGGER_H
9 #define BOOSTER_LOGGER_H
11 #include <booster/config.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 &);
270 void open(std::string file_name);
277 void max_files(
unsigned limit);
291 void set_timezone(std::string
const &name);
294 virtual void log(
message const &);
297 void shift(std::string
const &base);
298 std::string format_file(std::string
const &,
int);
302 size_t current_size_;
305 bool use_local_time_;
313 class BOOSTER_API syslog :
public sink {
328 virtual void log(
message const &);
359 #define BOOSTER_LOG(level,module) \
360 ::booster::log::logger::instance().should_be_logged(::booster::log::level,module) \
361 && ::booster::log::message(::booster::log::level,module,__FILE__,__LINE__).out()
365 #define BOOSTER_EMERG(m) BOOSTER_LOG(emergency,m)
366 #define BOOSTER_ALERT(m) BOOSTER_LOG(alert,m)
368 #define BOOSTER_CRITICAL(m) BOOSTER_LOG(critical,m)
370 #define BOOSTER_ERROR(m) BOOSTER_LOG(error,m)
372 #define BOOSTER_WARNING(m) BOOSTER_LOG(warning,m)
374 #define BOOSTER_NOTICE(m) BOOSTER_LOG(notice,m)
376 #define BOOSTER_INFO(m) BOOSTER_LOG(info,m)
378 #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:259
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)
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
This class makes impossible to copy any class derived from this one.
Definition: noncopyable.h:15