iplatypus::logger Class Reference

A cascading priorities logging tool. This object is thread-safe, it uses memory on the free store, so terminate() must be called. We now support a log level, which dictates which logs actually get written at all. The log level is set much like bind; that is, it cascades so setting log_level "warn" will write out only log entries with a priority of "warn", "error", and "fatal". More...

#include <logger.h>

List of all members.

Public Types

typedef enum iplatypus::logger::log_t priority
 debug = 0
 info
 warn
 error
 fatal
enum  log_t {
  debug = 0, info, warn, error,
  fatal
}
 The log priorities. debug < info < warn < error < fatal. More...

Public Member Functions

void bind (const log_t lt, const std::string &to_file=CONSOLE)
void bind_specific (const log_t lt, const std::string &to_file=CONSOLE)
void log_level (const log_t newlevel)
const log_t log_level (void) const
void write (const log_t lt, const std::string &msg)
void write (const std::string &srcfile, const log_t lt, const std::string &msg)
void write_debug (const std::string &msg)
void write_info (const std::string &msg)
void write_warn (const std::string &msg)
void write_error (const std::string &msg)
void write_fatal (const std::string &msg)

Static Public Member Functions

static loggerinstance (const std::string &src, const log_t level=warn)
static loggerinstance (const std::string &src, const std::string &homedir, const log_t level=warn)
static void terminate (void)

Protected Member Functions

 logger (void)
 logger (const std::string &src, const log_t level=warn)
 logger (const std::string &src, const std::string &homedir, const log_t level=warn)
virtual ~logger (void)
 logger (const logger &refcpy)
std::string timestamp (void)


Detailed Description

A cascading priorities logging tool. This object is thread-safe, it uses memory on the free store, so terminate() must be called. We now support a log level, which dictates which logs actually get written at all. The log level is set much like bind; that is, it cascades so setting log_level "warn" will write out only log entries with a priority of "warn", "error", and "fatal".


Member Typedef Documentation

typedef enum iplatypus::logger::log_t iplatypus::logger::priority


Member Enumeration Documentation

enum iplatypus::logger::log_t

The log priorities. debug < info < warn < error < fatal.

See also:
priority
Enumerator:
debug 
info 
warn 
error 
fatal 


Constructor & Destructor Documentation

iplatypus::logger::logger ( void   )  [inline, protected]

iplatypus::logger::logger ( const std::string &  src,
const log_t  level = warn 
) [protected]

iplatypus::logger::logger ( const std::string &  src,
const std::string &  homedir,
const log_t  level = warn 
) [protected]

virtual iplatypus::logger::~logger ( void   )  [inline, protected, virtual]

iplatypus::logger::logger ( const logger refcpy  )  [inline, protected]


Member Function Documentation

iplatypus::logger::bind ( const log_t  lt,
const std::string &  to_file = CONSOLE 
)

Binds a log priority to a specific file. When you bind a priority, itself, and all priorities greater than itself are all bound to the same file. For example, if you bind Log::warn to errors.log, then Log::warn, Log::error, and Log::fatal will all write to errors.log.

Parameters:
lt a log priority
to_file the file to bind the priority to.
See also:
log_t

bind_specific(log_t lt, const std::string& to_file = console)

Warning:
if you dont specifiy a file extension, .log will be appended

iplatypus::logger::bind_specific ( const log_t  lt,
const std::string &  to_file = CONSOLE 
)

Binds a log specific priority to a specific file. This version of bind suppresses the cascade effect.

Parameters:
lt a log_t log priority
to_file the file to bind the priority to.
See also:
log_t

bind(log_t lt, const std::string& to_file = CONSOLE)

iplatypus::logger::instance ( const std::string &  src,
const std::string &  homedir,
const log_t  level = warn 
) [static]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

A static member. Member for retreiving an instance of the singleton object. This should be used in place of the constructors.

Parameters:
src name of the file that this instance will be logging from
homedir name of the directory to store the logs in (default: logs/)
level log_t priority (or greater) to write out
See also:
instance(const std::string & src, const log_t level = warn)

Terminate(void)

static logger* iplatypus::logger::instance ( const std::string &  src,
const log_t  level = warn 
) [static]

const log_t iplatypus::logger::log_level ( void   )  const [inline]

iplatypus::logger::log_level ( const log_t  lt  )  [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Accessor for the currently set log level.

Parameters:
none 
Returns:
log_t value of the currently defined log level
See also:
log_t

log_level(const log_t newlevel)

iplatypus::logger::terminate ( void   )  [inline, static]

Releases dynamic memory from the heap; must be invoked prior to the destructor

Parameters:
none 
See also:
instance(const std::string & src, log_t level = warn)

instance(const std::string & src, const std::string & homedir, const log_t = warn);

std::string iplatypus::logger::timestamp ( void   )  [protected]

iplatypus::logger::write ( const std::string &  srcfile,
const log_t  lt,
const std::string &  msg 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Overloaded write to allow for the temporary redefinition of the source file.

Parameters:
srcfile name of the file the log entry is originating from.
lt a log priority
msg the log entry to write
See also:
log_t

write(const log_t lt, const std::string& msg)

Warning:
calls to write() for a priority lower than the currently set log level will be ignored.

iplatypus::logger::write ( const log_t  lt,
const std::string &  msg 
)

Writes out the log message to wherever the priority has been bound. Log messages are appended, so bear in mind that you'll have to do something to gaurd against oversized files. Obviously, messages bound to console are not an issue. messages are logged in the following format: timestamp | src_file | priority | message

Parameters:
lt a log priority
msg the log entry to write
See also:
log_t

write(const std::string & srcfile, const log_t lt, const std::string& msg)

Warning:
calls to write() for a priority lower than the currently set log level will be ignored.

iplatypus::logger::write_debug ( const std::string &  msg  )  [inline]

A convenience wrapper for debug entries

Parameters:
msg - string message to be logged
See also:
write(const log_t lt, const std::string& msg)

iplatypus::logger::write_error ( const std::string &  msg  )  [inline]

A convenience wrapper for debug entries

Parameters:
msg - string message to be logged
See also:
write(const log_t lt, const std::string& msg)

iplatypus::logger::write_fatal ( const std::string &  msg  )  [inline]

A convenience wrapper for debug entries

Parameters:
msg - string message to be logged
See also:
write(const log_t lt, const std::string& msg)

iplatypus::logger::write_info ( const std::string &  msg  )  [inline]

A convenience wrapper for debug entries

Parameters:
msg - string message to be logged
See also:
write(const log_t lt, const std::string& msg)

iplatypus::logger::write_warn ( const std::string &  msg  )  [inline]

A convenience wrapper for debug entries

Parameters:
msg - string message to be logged
See also:
write(const log_t lt, const std::string& msg)


The documentation for this class was generated from the following file:
Generated on Wed Nov 14 12:01:02 2012 for VetSim Applications by  doxygen 1.4.7