BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsls::Log Class Reference

#include <bsls_log.h>

Public Types

typedef void(* LogMessageHandler) (bsls::LogSeverity::Enum severity, const char *file, int line, const char *message)
 

Static Public Member Functions

static void logFormattedMessage (bsls::LogSeverity::Enum severity, const char *file, int line, const char *format,...)
 
static void logMessage (bsls::LogSeverity::Enum severity, const char *file, int line, const char *message)
 
static Log::LogMessageHandler logMessageHandler ()
 Return the address of the currently installed log message handler.
 
static void platformDefaultMessageHandler (bsls::LogSeverity::Enum severity, const char *file, int line, const char *message)
 
static void setLogMessageHandler (Log::LogMessageHandler handler)
 Install the specified handler as the current log message handler.
 
static void setSeverityThreshold (bsls::LogSeverity::Enum severity)
 
static bsls::LogSeverity::Enum severityThreshold ()
 
static void stderrMessageHandler (bsls::LogSeverity::Enum severity, const char *file, int line, const char *message)
 
static void stdoutMessageHandler (bsls::LogSeverity::Enum severity, const char *file, int line, const char *message)
 

Detailed Description

This class serves as a namespace containing a suite of utility functions that allow low-level code to write log messages to a configurable, globally controlled destination.

See bsls_log

Member Typedef Documentation

◆ LogMessageHandler

typedef void(* bsls::Log::LogMessageHandler) (bsls::LogSeverity::Enum severity, const char *file, int line, const char *message)

The LogMessageHandler typedef represents a type of function that handles log messages in an unspecified way (e.g., by writing the log message to an output stream or to a file). Because they can be called concurrently from multiple threads, log message handlers must be thread-safe. While installed, handlers must exhibit only defined behavior if the specified file is a null-terminated string, the specified line is not negative, and the specified message is a null-terminated string.

Member Function Documentation

◆ logFormattedMessage()

static void bsls::Log::logFormattedMessage ( bsls::LogSeverity::Enum  severity,
const char *  file,
int  line,
const char *  format,
  ... 
)
static

If the specified severity is at least as severe as severityThrehold, invoke the currently installed log message handler with severity and the specified file and line, as well as a message string created by calling sprintf on the specified format with the specified variadic arguments; otherwise (if severity is less severe), this operation has no effect. The behavior is undefined unless 0 <= line, and format is a valid sprintf format specification for the supplied variadic arguments.

◆ logMessage()

void bsls::Log::logMessage ( bsls::LogSeverity::Enum  severity,
const char *  file,
int  line,
const char *  message 
)
inlinestatic

If the specified severity is at least as severe as severityThreshold, invoke the currently installed log message handler with severity, as well as the specified file, line, and message; otherwise (if severity is less severe), this operation has no effect. The behavior is undefined unless 0 <= line.

◆ logMessageHandler()

Log::LogMessageHandler bsls::Log::logMessageHandler ( )
inlinestatic

◆ platformDefaultMessageHandler()

static void bsls::Log::platformDefaultMessageHandler ( bsls::LogSeverity::Enum  severity,
const char *  file,
int  line,
const char *  message 
)
static

Write, to a platform-specific destination, a string composed of the specified severity, file name, line number, and message. On non-Windows systems, write the log record to the stderr output stream. On Windows systems: If the current process is running in console mode, write the log record to the stderr output stream. If the current process is running in non-console mode, write the log record to the Windows process debugger. The behavior is undefined unless 0 <= line. Note that this function is used as the default log message handler. Also note that this function will write the message irrespective of the current severityThreshold.

◆ setLogMessageHandler()

void bsls::Log::setLogMessageHandler ( Log::LogMessageHandler  handler)
inlinestatic

◆ setSeverityThreshold()

void bsls::Log::setSeverityThreshold ( bsls::LogSeverity::Enum  severity)
inlinestatic

Set the severity threshold at which log records are written by logMessage and logFormattedMessage to the specified severity.

◆ severityThreshold()

bsls::LogSeverity::Enum bsls::Log::severityThreshold ( )
inlinestatic

Return the currently configured severity threshold at or above which records are written by logMessage and logFormattedMessage.

◆ stderrMessageHandler()

static void bsls::Log::stderrMessageHandler ( bsls::LogSeverity::Enum  severity,
const char *  file,
int  line,
const char *  message 
)
static

Write, to the stderr output stream, a string composed of the specified severity, file name, line number, and the message. The behavior is undefined unless 0 <= line. Note that this function provides an implementation of the LogMessageHandler function prototype, and will write the message irrespective of the current severityThreshold.

◆ stdoutMessageHandler()

static void bsls::Log::stdoutMessageHandler ( bsls::LogSeverity::Enum  severity,
const char *  file,
int  line,
const char *  message 
)
static

Write, to the stdout output stream, a string composed of the specified severity, file name, line number, and the message. The behavior is undefined unless 0 <= line. Note that this function provides an implementation of the LogMessageHandler function prototype, and will write the message irrespective of the current severityThreshold.


The documentation for this class was generated from the following file: