icedb  version 0.5.1
Snow particle scattering database API
Classes | Typedefs | Enumerations | Functions
icedb::logging Namespace Reference

Classes

struct  log_properties
 

Typedefs

typedef void(* log_handler_ft) (const char *, const char *, PRIORITIES)
 

Enumerations

enum  PRIORITIES {
  ICEDB_LOG_DEBUG_2, ICEDB_LOG_DEBUG_1, ICEDB_LOG_INFO, ICEDB_LOG_NORMAL,
  ICEDB_LOG_NOTIFICATION, ICEDB_LOG_DEBUG_WARNING, ICEDB_LOG_ERROR, ICEDB_LOG_CRITICAL
}
 

Functions

void emit_log (const std::string &channel, const std::string &message, PRIORITIES p)
 
void register_log_handler (log_handler_ft p)
 
void emit_log (const char *channel, const char *message, PRIORITIES p)
 
void setupLogging (int argc, char **argv, const log_properties *lps)
 

Typedef Documentation

◆ log_handler_ft

typedef void(* icedb::logging::log_handler_ft) (const char *, const char *, PRIORITIES)

Definition at line 27 of file logging.hpp.

Enumeration Type Documentation

◆ PRIORITIES

Enumerator
ICEDB_LOG_DEBUG_2 
ICEDB_LOG_DEBUG_1 
ICEDB_LOG_INFO 
ICEDB_LOG_NORMAL 
ICEDB_LOG_NOTIFICATION 
ICEDB_LOG_DEBUG_WARNING 
ICEDB_LOG_ERROR 
ICEDB_LOG_CRITICAL 

Definition at line 10 of file logging.hpp.

Function Documentation

◆ emit_log() [1/2]

void icedb::logging::emit_log ( const std::string &  channel,
const std::string &  message,
PRIORITIES  p 
)

Definition at line 16 of file logging.cpp.

20  {
21  emit_log(channel.c_str(), message.c_str(), p);
22  }
void emit_log(const char *channel, const char *message, PRIORITIES p)
Definition: logging.cpp:24

◆ emit_log() [2/2]

void icedb::logging::emit_log ( const char *  channel,
const char *  message,
PRIORITIES  p 
)

Definition at line 24 of file logging.cpp.

References ICEDB_writeDebugString(), anonymous_namespace{logging.cpp}::logConsoleThreshold, anonymous_namespace{logging.cpp}::logDebugThreshold, anonymous_namespace{logging.cpp}::logHandler, and anonymous_namespace{logging.cpp}::lOut.

28  {
29  if (logHandler) {
30  logHandler(channel, message, p);
31  }
32  else {
33  std::string m;
34  std::ostringstream out;
35  out << channel << " - " << message << std::endl;
36  m = out.str();
37  if (p >= logConsoleThreshold)
38  std::cerr << m;
39  if (p >= logDebugThreshold) {
40  ICEDB_writeDebugString(m.c_str());
41  }
42  if (lOut) {
43  *(lOut.get()) << m;
44  }
45  }
46  }
std::shared_ptr< std::ofstream > lOut
Definition: logging.cpp:11
icedb::logging::log_handler_ft logHandler
Definition: logging.cpp:12
void ICEDB_writeDebugString(const char *c)
Here is the call graph for this function:

◆ register_log_handler()

void icedb::logging::register_log_handler ( log_handler_ft  p)

Definition at line 23 of file logging.cpp.

References anonymous_namespace{logging.cpp}::logHandler.

23 { logHandler = p; }
icedb::logging::log_handler_ft logHandler
Definition: logging.cpp:12

◆ setupLogging()

void icedb::logging::setupLogging ( int  argc,
char **  argv,
const log_properties lps 
)

Definition at line 47 of file logging.cpp.

References icedb::logging::log_properties::consoleLogThreshold, icedb::logging::log_properties::debuggerLogThreshold, anonymous_namespace{logging.cpp}::logConsoleThreshold, anonymous_namespace{logging.cpp}::logDebugThreshold, anonymous_namespace{logging.cpp}::logFile, icedb::logging::log_properties::logFile, and anonymous_namespace{logging.cpp}::lOut.

50  {
51  if (lps) {
52  logConsoleThreshold = lps->consoleLogThreshold;
53  logDebugThreshold = lps->debuggerLogThreshold;
54  logFile = lps->logFile;
55  if (logFile.size()) {
56  lOut = std::shared_ptr<std::ofstream>(new std::ofstream(logFile.c_str()));
57  }
58  }
59  }
std::shared_ptr< std::ofstream > lOut
Definition: logging.cpp:11