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> 18 #include <booster/memory_inc.h> 78 char const *module()
const;
82 char const *file_name()
const;
86 int file_line()
const;
90 std::string log_message()
const;
99 char const *file_name_;
102 std::unique_ptr<std::ostringstream> message_;
121 virtual void log(
message const &m) = 0;
137 static logger &instance();
144 bool should_be_logged(
level_type level,
char const *module);
153 void set_log_level(
level_type level,
char const *module);
158 void reset_log_level(
char const *module);
170 void add_sink(shared_ptr<sink>
const &s);
176 void remove_sink(weak_ptr<sink>
const &s);
181 void remove_all_sinks();
192 static char const *level_to_string(
level_type level);
196 static level_type string_to_level(std::string
const &);
205 static const int max_entries_size_ = 1024;
207 entry entries_[max_entries_size_];
244 virtual void log(
message const &);
266 virtual void log(
message const &msg);
285 static const int app = -1;
298 file(std::string
const &file_name,
int max_files = 0);
305 void open(std::string file_name);
312 void max_files(
unsigned limit);
326 void set_timezone(std::string
const &name);
329 virtual void log(
message const &);
332 void shift(std::string
const &base);
333 std::string format_file(std::string
const &,
int);
336 BOOSTER_UNUSED_MEMBER
size_t max_size_;
337 BOOSTER_UNUSED_MEMBER
size_t current_size_;
340 bool use_local_time_;
348 class BOOSTER_API syslog :
public sink {
364 syslog(std::string
const &
id,
int opts,
int facility = 0);
368 syslog(
int opts,
int facility = 0);
372 virtual void log(
message const &);
403 #define BOOSTER_LOG(level,module) \ 404 ::booster::log::logger::instance().should_be_logged(::booster::log::level,module) \ 405 && ::booster::log::message(::booster::log::level,module,__FILE__,__LINE__).out() 409 #define BOOSTER_EMERG(m) BOOSTER_LOG(emergency,m) 410 #define BOOSTER_ALERT(m) BOOSTER_LOG(alert,m) 412 #define BOOSTER_CRITICAL(m) BOOSTER_LOG(critical,m) 414 #define BOOSTER_ERROR(m) BOOSTER_LOG(error,m) 416 #define BOOSTER_WARNING(m) BOOSTER_LOG(warning,m) 418 #define BOOSTER_NOTICE(m) BOOSTER_LOG(notice,m) 420 #define BOOSTER_INFO(m) BOOSTER_LOG(info,m) 422 #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:112
log file based sink - sends messages to log file
Definition: log.h:277
This is the central class that manages all logging operations.
Definition: log.h:132
BOOSTER_API std::string format_plain_text_message(message const &msg)
stderr based sink - sends messages to standard error output
Definition: log.h:241
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:257
This class represents a single message that should be written to log.
Definition: log.h:52
level_type
Definition: log.h:33
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