0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Namespaces | Macros | Enumerations | Functions
Logger.h File Reference

Logging routines and macros. More...

#include "Error.h"
#include "String.h"
#include <iostream>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include "FixedStream.h"
Include dependency graph for Logger.h:

Go to the source code of this file.

Classes

class  Hypertable::Logger::LogWriter
 The LogWriter class writes to stdout. More...
 

Namespaces

 Hypertable
 Hypertable definitions
 
 Hypertable::Logger
 Logging framework.
 
 Hypertable::Logger::Priority
 Output priorities modelled after syslog.
 

Macros

#define HT_LOG_BUFSZ   1024
 
#define HT_ABORT   raise(SIGABRT)
 
#define HT_LOG(priority, msg)
 
#define HT_LOGF(priority, fmt,...)
 
#define HT_LOG_BUF_SIZE   4096
 
#define HT_OUT(priority)
 
#define HT_OUT2(priority)
 
#define HT_END
 
#define HT_OUT_DISABLED   do { if (0) {
 
#define HT_DUMP_CSTR(_os_, _label_, _str_)
 
#define HT_DUMP_CSTR_FIELD(_os_, _obj_, _field_)   HT_DUMP_CSTR(_os_, _field_, _obj_._field_)
 
#define HT_LOG_ENTER
 
#define HT_LOG_EXIT
 
#define HT_DEBUG(msg)   HT_LOG(Logger::Priority::DEBUG, msg)
 
#define HT_DEBUGF(msg,...)   HT_LOGF(Logger::Priority::DEBUG, msg, __VA_ARGS__)
 
#define HT_DEBUG_OUT   HT_OUT2(Logger::Priority::DEBUG)
 
#define HT_INFO(msg)   HT_LOG(Logger::Priority::INFO, msg)
 
#define HT_INFOF(msg,...)   HT_LOGF(Logger::Priority::INFO, msg, __VA_ARGS__)
 
#define HT_NOTICE(msg)   HT_LOG(Logger::Priority::NOTICE, msg)
 
#define HT_NOTICEF(msg,...)   HT_LOGF(Logger::Priority::NOTICE, msg, __VA_ARGS__)
 
#define HT_NOTICE_OUT   HT_OUT(Logger::Priority::NOTICE)
 
#define HT_WARN(msg)   HT_LOG(Logger::Priority::WARN, msg)
 
#define HT_WARNF(msg,...)   HT_LOGF(Logger::Priority::WARN, msg, __VA_ARGS__)
 
#define HT_WARN_OUT   HT_OUT2(Logger::Priority::WARN)
 
#define HT_ERROR(msg)   HT_LOG(Logger::Priority::ERROR, msg)
 
#define HT_ERRORF(msg,...)   HT_LOGF(Logger::Priority::ERROR, msg, __VA_ARGS__)
 
#define HT_ERROR_OUT   HT_OUT2(Logger::Priority::ERROR)
 
#define HT_CRIT(msg)   HT_LOG(Logger::Priority::CRIT, msg)
 
#define HT_CRITF(msg,...)   HT_LOGF(Logger::Priority::CRIT, msg, __VA_ARGS__)
 
#define HT_CRIT_OUT   HT_OUT2(Logger::Priority::CRIT)
 
#define HT_ALERT(msg)   HT_LOG(Logger::Priority::ALERT, msg)
 
#define HT_ALERTF(msg,...)   HT_LOGF(Logger::Priority::ALERT, msg, __VA_ARGS__)
 
#define HT_ALERT_OUT   HT_OUT2(Logger::Priority::ALERT)
 
#define HT_EMERG(msg)   HT_LOG(Logger::Priority::EMERG, msg)
 
#define HT_EMERGF(msg,...)   HT_LOGF(Logger::Priority::EMERG, msg, __VA_ARGS__)
 
#define HT_EMERG_OUT   HT_OUT2(Logger::Priority::EMERG)
 
#define HT_FATAL(msg)
 
#define HT_FATALF(msg,...)
 
#define HT_FATAL_OUT   HT_OUT2(Logger::Priority::FATAL)
 
#define HT_EXPECT(_e_, _code_)
 
#define HT_ASSERT(_e_)   HT_EXPECT(_e_, Error::FAILED_EXPECTATION)
 

Enumerations

enum  {
  Hypertable::Logger::Priority::EMERG = 0, Hypertable::Logger::Priority::FATAL = 0, Hypertable::Logger::Priority::ALERT = 1, Hypertable::Logger::Priority::CRIT = 2,
  Hypertable::Logger::Priority::ERROR = 3, Hypertable::Logger::Priority::WARN = 4, Hypertable::Logger::Priority::NOTICE = 5, Hypertable::Logger::Priority::INFO = 6,
  Hypertable::Logger::Priority::DEBUG = 7, Hypertable::Logger::Priority::NOTSET = 8
}
 

Functions

void Hypertable::Logger::initialize (const String &name)
 Public initialization function - creates a singleton instance of LogWriter. More...
 
LogWriter * Hypertable::Logger::get ()
 Accessor for the LogWriter singleton instance. More...
 

Detailed Description

Logging routines and macros.

The LogWriter provides facilities to write debug, log, error- and other messages to stdout. The Logging namespaces provides std::ostream- and printf-like macros and convenience functions.

Definition in file Logger.h.

Macro Definition Documentation

#define HT_ABORT   raise(SIGABRT)

Definition at line 175 of file Logger.h.

#define HT_ALERT (   msg)    HT_LOG(Logger::Priority::ALERT, msg)

Definition at line 319 of file Logger.h.

#define HT_ALERT_OUT   HT_OUT2(Logger::Priority::ALERT)

Definition at line 321 of file Logger.h.

#define HT_ALERTF (   msg,
  ... 
)    HT_LOGF(Logger::Priority::ALERT, msg, __VA_ARGS__)

Definition at line 320 of file Logger.h.

#define HT_ASSERT (   _e_)    HT_EXPECT(_e_, Error::FAILED_EXPECTATION)

Definition at line 396 of file Logger.h.

#define HT_CRIT (   msg)    HT_LOG(Logger::Priority::CRIT, msg)

Definition at line 309 of file Logger.h.

#define HT_CRIT_OUT   HT_OUT2(Logger::Priority::CRIT)

Definition at line 311 of file Logger.h.

#define HT_CRITF (   msg,
  ... 
)    HT_LOGF(Logger::Priority::CRIT, msg, __VA_ARGS__)

Definition at line 310 of file Logger.h.

#define HT_DEBUG (   msg)    HT_LOG(Logger::Priority::DEBUG, msg)

Definition at line 259 of file Logger.h.

#define HT_DEBUG_OUT   HT_OUT2(Logger::Priority::DEBUG)

Definition at line 261 of file Logger.h.

#define HT_DEBUGF (   msg,
  ... 
)    HT_LOGF(Logger::Priority::DEBUG, msg, __VA_ARGS__)

Definition at line 260 of file Logger.h.

#define HT_DUMP_CSTR (   _os_,
  _label_,
  _str_ 
)
Value:
do { \
if (!_str_) _os_ <<" " #_label_ "=[NULL]"; \
else _os_ <<" " #_label_ "='"<< (_str_) << "'"; \
} while (0)

Definition at line 227 of file Logger.h.

#define HT_DUMP_CSTR_FIELD (   _os_,
  _obj_,
  _field_ 
)    HT_DUMP_CSTR(_os_, _field_, _obj_._field_)

Definition at line 232 of file Logger.h.

#define HT_EMERG (   msg)    HT_LOG(Logger::Priority::EMERG, msg)

Definition at line 329 of file Logger.h.

#define HT_EMERG_OUT   HT_OUT2(Logger::Priority::EMERG)

Definition at line 331 of file Logger.h.

#define HT_EMERGF (   msg,
  ... 
)    HT_LOGF(Logger::Priority::EMERG, msg, __VA_ARGS__)

Definition at line 330 of file Logger.h.

#define HT_END
Value:
""; Logger::get()->log(_priority_, _out_.str()); \
if (_priority_ == Logger::Priority::FATAL) HT_ABORT; \
} /* if enabled */ } while (0)
#define HT_ABORT
Definition: Logger.h:175
T get(const String &name)
Retrieves a configuration value.
Definition: Config.h:82

Definition at line 220 of file Logger.h.

#define HT_ERROR (   msg)    HT_LOG(Logger::Priority::ERROR, msg)

Definition at line 299 of file Logger.h.

#define HT_ERROR_OUT   HT_OUT2(Logger::Priority::ERROR)

Definition at line 301 of file Logger.h.

#define HT_ERRORF (   msg,
  ... 
)    HT_LOGF(Logger::Priority::ERROR, msg, __VA_ARGS__)

Definition at line 300 of file Logger.h.

#define HT_EXPECT (   _e_,
  _code_ 
)
Value:
do { if (_e_); else { \
HT_FATAL("failed expectation: " #_e_); \
HT_THROW(_code_, "failed expectation: " #_e_); } \
} while (0)
#define HT_FATAL(msg)
Definition: Logger.h:339
#define HT_THROW(_code_, _msg_)
Definition: Error.h:478

Definition at line 388 of file Logger.h.

#define HT_FATAL (   msg)
Value:
do { \
} while (0)
#define HT_ABORT
Definition: Logger.h:175
#define HT_LOG(priority, msg)
Definition: Logger.h:179

Definition at line 339 of file Logger.h.

#define HT_FATAL_OUT   HT_OUT2(Logger::Priority::FATAL)

Definition at line 347 of file Logger.h.

#define HT_FATALF (   msg,
  ... 
)
Value:
do { \
HT_LOGF(Logger::Priority::FATAL, msg, __VA_ARGS__); \
} while (0)
#define HT_ABORT
Definition: Logger.h:175
#define HT_LOGF(priority, fmt,...)
Definition: Logger.h:189

Definition at line 343 of file Logger.h.

#define HT_INFO (   msg)    HT_LOG(Logger::Priority::INFO, msg)

Definition at line 271 of file Logger.h.

#define HT_INFOF (   msg,
  ... 
)    HT_LOGF(Logger::Priority::INFO, msg, __VA_ARGS__)

Definition at line 272 of file Logger.h.

#define HT_LOG (   priority,
  msg 
)
Value:
do { \
if (Logger::get()->is_enabled(priority)) { \
if (Logger::get()->show_line_numbers()) \
Logger::get()->log(priority, Hypertable::format( \
"(%s:%d) %s", __FILE__, __LINE__, msg)); \
Logger::get()->log(priority, msg); \
} \
} while (0)
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
Definition: String.cc:37
T get(const String &name)
Retrieves a configuration value.
Definition: Config.h:82

Definition at line 179 of file Logger.h.

#define HT_LOG_BUF_SIZE   4096

Definition at line 201 of file Logger.h.

#define HT_LOG_BUFSZ   1024

Definition at line 169 of file Logger.h.

#define HT_LOG_ENTER
Value:
do { \
if (Logger::get()->is_enabled(Logger::Priority::DEBUG)) {\
if (Logger::get()->show_line_numbers()) \
Logger::get()->debug("(%s:%d) %s() ENTER", __FILE__, __LINE__, HT_FUNC);\
Logger::get()->debug("%s() ENTER", HT_FUNC); \
} \
} while(0)
#define HT_FUNC
Definition: compat-c.h:65
T get(const String &name)
Retrieves a configuration value.
Definition: Config.h:82

Definition at line 241 of file Logger.h.

#define HT_LOG_EXIT
Value:
do { \
if (Logger::get()->is_enabled(Logger::Priority::DEBUG)) { \
if (Logger::get()->show_line_numbers()) \
Logger::get()->debug("(%s:%d) %s() EXIT", __FILE__, __LINE__, HT_FUNC); \
Logger::get()->debug("%s() EXIT", HT_FUNC); \
} \
} while(0)
#define HT_FUNC
Definition: compat-c.h:65
T get(const String &name)
Retrieves a configuration value.
Definition: Config.h:82

Definition at line 250 of file Logger.h.

#define HT_LOGF (   priority,
  fmt,
  ... 
)
Value:
do { \
if (Logger::get()->is_enabled(priority)) { \
if (Logger::get()->show_line_numbers()) \
Logger::get()->log(priority, Hypertable::format( \
"(%s:%d) " fmt, __FILE__, __LINE__, __VA_ARGS__)); \
Logger::get()->log(priority, Hypertable::format( \
fmt, __VA_ARGS__)); \
} \
} while (0)
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
Definition: String.cc:37
T get(const String &name)
Retrieves a configuration value.
Definition: Config.h:82

Definition at line 189 of file Logger.h.

#define HT_NOTICE (   msg)    HT_LOG(Logger::Priority::NOTICE, msg)

Definition at line 279 of file Logger.h.

#define HT_NOTICE_OUT   HT_OUT(Logger::Priority::NOTICE)

Definition at line 281 of file Logger.h.

#define HT_NOTICEF (   msg,
  ... 
)    HT_LOGF(Logger::Priority::NOTICE, msg, __VA_ARGS__)

Definition at line 280 of file Logger.h.

#define HT_OUT (   priority)
Value:
do { if (Logger::get()->is_enabled(priority)) { \
char logbuf[HT_LOG_BUF_SIZE]; \
int _priority_ = Logger::get()->get_level(); \
FixedOstream _out_(logbuf, sizeof(logbuf)); \
if (Logger::get()->show_line_numbers()) \
_out_ <<"("<< __FILE__ <<':'<< __LINE__ <<") "; \
_out_
T get(const String &name)
Retrieves a configuration value.
Definition: Config.h:82
#define HT_LOG_BUF_SIZE
Definition: Logger.h:201

Definition at line 203 of file Logger.h.

#define HT_OUT2 (   priority)
Value:
do { if (Logger::get()->is_enabled(priority)) { \
char logbuf[HT_LOG_BUF_SIZE]; \
int _priority_ = priority; \
FixedOstream _out_(logbuf, sizeof(logbuf)); \
_out_ << __func__; \
if (Logger::get()->show_line_numbers()) \
_out_ << " ("<< __FILE__ <<':'<< __LINE__ <<")"; \
_out_ <<": "
T get(const String &name)
Retrieves a configuration value.
Definition: Config.h:82
#define HT_LOG_BUF_SIZE
Definition: Logger.h:201

Definition at line 211 of file Logger.h.

#define HT_OUT_DISABLED   do { if (0) {

Definition at line 224 of file Logger.h.

#define HT_WARN (   msg)    HT_LOG(Logger::Priority::WARN, msg)

Definition at line 289 of file Logger.h.

#define HT_WARN_OUT   HT_OUT2(Logger::Priority::WARN)

Definition at line 291 of file Logger.h.

#define HT_WARNF (   msg,
  ... 
)    HT_LOGF(Logger::Priority::WARN, msg, __VA_ARGS__)

Definition at line 290 of file Logger.h.