ErrLog Class Reference

Inherited by w_debug.

Inheritance diagram for ErrLog:

Inheritance graph
[legend]
Collaboration diagram for ErrLog:

Collaboration graph
[legend]
List of all members.

Detailed Description

A syslog-style output stream for logging errors, information, etc.

This output stream is used for issuing errors, "information", debugging tracing, etc. to the operator (e.g., stderr) or to a file, somewhat like syslog.

Attention:
This predates true multi-threading and is thus not thread-safe. We have not yet replaced this code, with a thread-safe version. It is still useful for debugging non-timing-dependent issues, for issuing operator messages before multithreading really starts, e.g., during recovery.
Example:
 ErrLog errlog(log_to_unix_file, "sm.errlog");
 errlog->clog << info_prio << "Restart recovery : analysis phase " << flushl;

Definition at line 193 of file errlog.h.

Public Member Functions

 ErrLog (const char *ident, LoggingDestination dest, const char *filename=0, LogPriority level=default_prio, char *ownbuf=0, int ownbufsz=0)
 ErrLog (const char *ident, LoggingDestination dest, FILE *file=0, LogPriority level=default_prio, char *ownbuf=0, int ownbufsz=0)
 ~ErrLog ()
void log (enum LogPriority prio, const char *format,...)
const char * ident ()
LoggingDestination destination ()
LogPriority getloglevel ()
const char * getloglevelname ()
LogPriority setloglevel (LogPriority prio)

Static Public Member Functions

static LogPriority parse (const char *arg, bool *ok=0)

Public Attributes

logstream clog

Friends

logstreamis_logstream (ostream &)
ostream & flush_and_setprio (ostream &o, LogPriority p)


Constructor & Destructor Documentation

ErrLog::ErrLog ( const char *  ident,
LoggingDestination  dest,
const char *  filename = 0,
LogPriority  level = default_prio,
char *  ownbuf = 0,
int  ownbufsz = 0 
)

Create a log.

Parameters:
[in] ident The name of the log.
[in] dest Indicates destination (unix file, stderr, etc).
[in] filename Name of destination or "-' .
[in] level Minimum priority level of messages to be sent to the file. For filtering.
[in] ownbuf Buffer to use. Default is NULL.
[in] ownbufsz Size of given buffer. Default is 0.
Using the name "-" is the same as specifying log_to_stderr

Definition at line 233 of file errlog.cpp.

References W_FATAL_MSG.

ErrLog::ErrLog ( const char *  ident,
LoggingDestination  dest,
FILE *  file = 0,
LogPriority  level = default_prio,
char *  ownbuf = 0,
int  ownbufsz = 0 
)

Create a log.

Parameters:
[in] ident The name of the log.
[in] dest Indicates destination (unix file, stderr, etc).
[in] file Already open FILE*. Default is NULL.
[in] level Minimum priority level of messages to be sent to the file. For filtering.
[in] ownbuf Buffer to use. Default is NULL.
[in] ownbufsz Size of given buffer. Default is 0.

Definition at line 280 of file errlog.cpp.

References w_assert9.


Member Function Documentation

LogPriority ErrLog::parse ( const char *  arg,
bool *  ok = 0 
) [static]

Convert a char string to an enumeration value.

Parameters:
[in] arg The string to parse.
[out] ok Returns true/false if parse worked/not (optional)

Definition at line 136 of file errlog.cpp.

void ErrLog::log ( enum LogPriority  prio,
const char *  format,
  ... 
)

Format and issue a message with the given priority, that is, don't issue it unless this priority is equal to or higher than the priority of this error log.

Definition at line 333 of file errlog.cpp.

References w_reset_strstream.

const char* ErrLog::ident (  )  [inline]

Return the name of the file if known

Definition at line 269 of file errlog.h.

LogPriority ErrLog::getloglevel (  )  [inline]

Return the current logging level

Definition at line 275 of file errlog.h.

const char* ErrLog::getloglevelname (  )  [inline]

Return a static string describing the current logging level

Definition at line 278 of file errlog.h.

LogPriority ErrLog::setloglevel ( LogPriority  prio  )  [inline]

Change the current logging level

Definition at line 305 of file errlog.h.


Member Data Documentation

logstream ErrLog::clog

A stream that can be used with operator<<. Example:

 ErrLog E("XXX", log_to_unix_file, "XXX.out");
 E->clog << obj << endl;

Definition at line 260 of file errlog.h.


The documentation for this class was generated from the following files:
Generated on Wed Jul 7 17:22:43 2010 for Shore Storage Manager by  doxygen 1.4.7