#include <Log_Msg.h>
Collaboration diagram for ACE_Log_Msg:
Public Types | |
enum | { STDERR = 1, LOGGER = 2, OSTREAM = 4, MSG_CALLBACK = 8, VERBOSE = 16, VERBOSE_LITE = 32, SILENT = 64, SYSLOG = 128, CUSTOM = 256 } |
enum | MASK_TYPE { PROCESS = 0, THREAD = 1 } |
Public Methods | |
ACE_Log_Msg (void) | |
Initialize logger. More... | |
~ACE_Log_Msg (void) | |
cleanup logger. More... | |
int | open (const ACE_TCHAR *prog_name, u_long options_flags=ACE_Log_Msg::STDERR, const ACE_TCHAR *logger_key=0) |
Initialize the ACE logging facility. More... | |
void | set_flags (u_long f) |
Enable the bits in the logger's options flags. More... | |
void | clr_flags (u_long f) |
Disable the bits in the logger's options flags. More... | |
u_long | flags (void) |
Return the bits in the logger's options flags. More... | |
void | sync (const ACE_TCHAR *program_name) |
Call after doing a fork() to resynchronize the process id and program_name_ variables. More... | |
void | op_status (int status) |
Set the result of the operation status (by convention, -1 means error). More... | |
int | op_status (void) |
Get the result of the operation status (by convention, -1 means error). More... | |
void | errnum (int) |
Set the value of the errnum (by convention this corresponds to errno). More... | |
int | errnum (void) |
Get the value of the errnum (by convention this corresponds to errno). More... | |
void | linenum (int) |
Set the line number where an error occurred. More... | |
int | linenum (void) |
Get the line number where an error occurred. More... | |
void | file (const char *) |
Set the file name where an error occurred. More... | |
const char * | file (void) |
Get the file name where an error occurred. More... | |
void | msg (const ACE_TCHAR *) |
Set the message that describes what type of error occurred. More... | |
const ACE_TCHAR * | msg (void) |
Get the message that describes what type of error occurred. More... | |
void | restart (int) |
Set the field that indicates whether interrupted calls should be restarted. More... | |
int | restart (void) |
Get the field that indicates whether interrupted calls should be restarted. More... | |
void | msg_ostream (ACE_OSTREAM_TYPE *) |
Update the ostream without overwriting the delete_ostream_ flag. More... | |
void | msg_ostream (ACE_OSTREAM_TYPE *, int delete_ostream) |
delete_stream == 1, forces Log_Msg.h to delete the stream in its own ~dtor (assumes control of the stream) use only with proper ostream (eg: fstream), not (cout, cerr). More... | |
ACE_OSTREAM_TYPE * | msg_ostream (void) const |
Get the ostream that is used to print error messages. More... | |
ACE_Log_Msg_Callback * | msg_callback (ACE_Log_Msg_Callback *c) |
Set a new callback object and return the existing callback to allow "chaining". More... | |
ACE_Log_Msg_Callback * | msg_callback (void) const |
int | inc (void) |
Nesting depth increment. More... | |
int | dec (void) |
Nesting depth decrement. More... | |
int | trace_depth (void) |
Get trace depth. More... | |
void | trace_depth (int) |
Set trace depth. More... | |
int | trace_active (void) |
Set trace active status. More... | |
void | trace_active (int value) |
Get trace active status. More... | |
ACE_Thread_Descriptor * | thr_desc (void) const |
Get the TSS thread descriptor. More... | |
void | thr_desc (ACE_Thread_Descriptor *td) |
Set the TSS thread descriptor. More... | |
void | stop_tracing (void) |
Stop tracing status on a per-thread basis... More... | |
void | start_tracing (void) |
Start tracing status on a per-thread basis... More... | |
int | tracing_enabled (void) |
Query tracing status on a per-thread basis... More... | |
u_long | priority_mask (MASK_TYPE=THREAD) |
Get the current ACE_Log_Priority mask. More... | |
u_long | priority_mask (u_long, MASK_TYPE=THREAD) |
Set the ACE_Log_Priority mask, returns original mask. More... | |
int | log_priority_enabled (ACE_Log_Priority log_priority) |
Return true if the requested priority is enabled. More... | |
int | log_priority_enabled (ACE_Log_Priority log_priority, const char *,...) |
Return true if the requested priority is enabled. More... | |
pid_t | getpid (void) const |
Optimize reading of the pid (avoids a system call if the value is cached...). More... | |
const ACE_TCHAR * | local_host (void) const |
Get the name of the local host. More... | |
void | local_host (const ACE_TCHAR *) |
Set the name of the local host. More... | |
void | set (const char *file, int line, int op_status=-1, int errnum=0, int restart=1, ACE_OSTREAM_TYPE *os=0, ACE_Log_Msg_Callback *c=0) |
Set the line number, file name, operational status, error number, restart flag, ostream, and the callback object. More... | |
void | conditional_set (const char *file, int line, int op_status, int errnum) |
These values are only actually set if the requested priority is enabled. More... | |
ssize_t | log (ACE_Log_Priority priority, const ACE_TCHAR *format,...) |
Format a message to the thread-safe ACE logging mechanism. More... | |
ssize_t | log (ACE_Log_Priority priority, const ACE_ANTI_TCHAR *format,...) |
Since this is the ANTI_TCHAR version, we need to convert the format string over. More... | |
ssize_t | log (const ACE_TCHAR *format, ACE_Log_Priority priority, va_list argp) |
An alternative logging mechanism that makes it possible to integrate variable argument lists from other logging mechanisms into the ACE mechanism. More... | |
ssize_t | log (ACE_Log_Record &log_record, int suppress_stderr=0) |
Log a custom built log record to the currently enabled logging sinks. More... | |
int | log_hexdump (ACE_Log_Priority log_priority, const char *buffer, size_t size, const ACE_TCHAR *text=0) |
Method to log hex dump. More... | |
void | dump (void) const |
Dump the state of an object. More... | |
Allow apps to acquire and release internal synchronization | |
lock
This lock is used internally by the ACE_Log_Msg implementation. By exporting the lock, applications can hold the lock atomically over a number of calls to ACE_Log_Msg. | |
int | acquire (void) |
Acquire the internal lock. More... | |
int | release (void) |
Release the internal lock. More... | |
Static Public Methods | |
ACE_Log_Msg * | instance (void) |
Returns a pointer to the Singleton. More... | |
int | last_error_adapter (void) |
Returns last error. More... | |
int | exists (void) |
Returns non-null if an ACE_Log_Msg exists for the calling thread. More... | |
const ACE_TCHAR * | program_name (void) |
Returns the current program name used for logging. More... | |
void | disable_debug_messages (ACE_Log_Priority priority=LM_DEBUG) |
Clears the flag from the default priority mask used to initialize ACE_Log_Msg instances. More... | |
void | enable_debug_messages (ACE_Log_Priority priority=LM_DEBUG) |
Sets the flag in the default priority mask used to initialize ACE_Log_Msg instances. More... | |
ACE_Log_Msg_Backend * | msg_backend (ACE_Log_Msg_Backend *b) |
Set a new backend object and return the existing backend to allow "chaining". More... | |
ACE_Log_Msg_Backend * | msg_backend (void) |
void | init_hook (ACE_OS_Log_Msg_Attributes &attributes) |
void | inherit_hook (ACE_OS_Thread_Descriptor *thr_desc, ACE_OS_Log_Msg_Attributes &attributes) |
Inherit hook, the attributes field is a ACE_OS_Log_Msg_Attributes object, invoke the inherit_log_msg() method on it, then destroy it and set the attribute argument to 0. More... | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. More... | |
Private Methods | |
ACE_Log_Msg & | operator= (const ACE_Log_Msg &) |
ACE_Log_Msg (const ACE_Log_Msg &) | |
Static Private Methods | |
void | close (void) |
For cleanup, at program termination. More... | |
void | sync_hook (const ACE_TCHAR *prg_name) |
Decouple the OS layer from the ACE_Log_Msg layer. More... | |
ACE_OS_Thread_Descriptor * | thr_desc_hook (void) |
Return the TSS singleton thread descriptor. More... | |
Private Attributes | |
int | status_ |
Status of operation (-1 means failure, >= 0 means success). More... | |
int | errnum_ |
Type of error that occurred (see <sys/errno.h>). More... | |
int | linenum_ |
Line number where the error occurred. More... | |
char | file_ [MAXPATHLEN+1] |
File where the error occurred. More... | |
ACE_TCHAR | msg_ [ACE_MAXLOGMSGLEN+1] |
The log message, which resides in thread-specific storage. Note that only the current log message is stored here -- it will be overwritten by the subsequent call to log(). More... | |
int | restart_ |
Indicates whether we should restart system calls that are interrupted. More... | |
ACE_OSTREAM_TYPE * | ostream_ |
The ostream where logging messages can be written. More... | |
ACE_Log_Msg_Callback * | msg_callback_ |
The callback object. More... | |
int | trace_depth_ |
Depth of the nesting for printing traces. More... | |
int | trace_active_ |
Are we already within an ACE_Trace constructor call? More... | |
int | tracing_enabled_ |
Are we allowing tracing in this thread? More... | |
int | delete_ostream_ |
Are we deleting this ostream? More... | |
ACE_Thread_Descriptor * | thr_desc_ |
If we're running in the context of an ACE_Thread_Manager this will point to the thread descriptor adapter which holds the thread descriptor of the thread. More... | |
u_long | priority_mask_ |
Keeps track of all the per-thread ACE_Log_Priority values that are currently enabled. More... | |
struct { | |
int is_set_ | |
const char * file_ | |
int line_ | |
int op_status_ | |
int errnum_ | |
} | conditional_values_ |
Anonymous struct since there will only be one instance. This struct keeps information stored away in case we actually end up calling log() if the log priority is correct. More... | |
Static Private Attributes | |
u_long | process_priority_mask_ |
Keeps track of all the per-process ACE_Log_Priority values that are currently enabled. More... | |
const ACE_TCHAR * | program_name_ = 0 |
Records the program name. More... | |
const ACE_TCHAR * | local_host_ = 0 |
Name of the local host (used when printing messages). More... | |
pid_t | pid_ = -1 |
Process id of the current process. More... | |
u_long | flags_ = ACE_Log_Msg::STDERR |
Options flags. More... | |
int | msg_off_ = 0 |
Offset of msg_[]. More... | |
int | instance_count_ = 0 |
Number of existing ACE_Log_Msg instances; when 0, delete program/host names. More... | |
u_long | default_priority_mask_ = 0 |
Priority mask to use for each new instance. More... |
This class is very flexible since it allows formatted error messages to be printed in a thread-safe manner to various locations, such as stdout, stderr, cerr, a distributed logger, etc. The current message is also kept in a thread-specific storage location (threads spawned using ACE_Thread_Manager automatically get an ACE_Log_Msg object that inherits the spawning thread's settings), which can be used to communicate errors between framework methods and callers. A message is logged by the log() method, only if the message priority is currently enabled. Moreover, only the current log message is stored here -- it will be overwritten by the subsequent call to log().
The ACE_Log_Msg class uses two priority masks to control its logging behavior. The priority_mask_
object attribute is thread- specific and specifies the priority levels logged by the thread. The process_priority_mask_
class attribute is not thread-specific and specifies the priority levels that will be logged by all threads in the process. By default, all levels are disabled for priority_mask_
and all levels are enabled for process_priority_mask_
(i.e. the process-wide mask controls the settings, and each instance can expand on it if desired). Both priority masks can be modified using the priority_mask() method of this class.
|
|
|
|
Initialize logger.
|
|
cleanup logger.
|
|
|
|
Acquire the internal lock.
|
|
For cleanup, at program termination.
|
|
Disable the bits in the logger's options flags.
|
|
These values are only actually set if the requested priority is enabled.
|
|
Nesting depth decrement.
|
|
Clears the flag from the default priority mask used to initialize ACE_Log_Msg instances.
|
|
Dump the state of an object.
|
|
Sets the flag in the default priority mask used to initialize ACE_Log_Msg instances.
|
|
Get the value of the errnum (by convention this corresponds to errno).
|
|
Set the value of the errnum (by convention this corresponds to errno).
|
|
Returns non-null if an ACE_Log_Msg exists for the calling thread.
|
|
Get the file name where an error occurred.
|
|
Set the file name where an error occurred.
|
|
Return the bits in the logger's options flags.
|
|
Optimize reading of the pid (avoids a system call if the value is cached...).
|
|
Nesting depth increment.
|
|
Inherit hook, the attributes field is a ACE_OS_Log_Msg_Attributes object, invoke the inherit_log_msg() method on it, then destroy it and set the attribute argument to 0.
|
|
|
|
Returns a pointer to the Singleton.
|
|
Returns last error.
|
|
Get the line number where an error occurred.
|
|
Set the line number where an error occurred.
|
|
Set the name of the local host.
|
|
Get the name of the local host.
|
|
Log a custom built log record to the currently enabled logging sinks.
|
|
An alternative logging mechanism that makes it possible to integrate variable argument lists from other logging mechanisms into the ACE mechanism.
|
|
Since this is the ANTI_TCHAR version, we need to convert the format string over.
|
|
Format a message to the thread-safe ACE logging mechanism. Valid options (prefixed by '%', as in printf format strings) include:
|
|
Method to log hex dump. This is useful for debugging. Calls log() to do the actual print, but formats first to make the chars printable. |
|
Return true if the requested priority is enabled.
|
|
Return true if the requested priority is enabled.
|
|
Get the message that describes what type of error occurred.
|
|
Set the message that describes what type of error occurred.
|
|
|
|
Set a new backend object and return the existing backend to allow "chaining". Note that as opposed to ACE_Log_Msg_Callback, ACE_Log_Msg_Backend is a per-process entity. Note: Be aware that because of the current architecture there is no guarantee that open (), reset () and close () will be called on a backend object. |
|
|
|
Set a new callback object and return the existing callback to allow "chaining". Note that ACE_Log_Msg_Callback objects are not inherited when spawning a new thread, so you'll need to reset them in each thread. |
|
Get the ostream that is used to print error messages.
|
|
delete_stream == 1, forces Log_Msg.h to delete the stream in its own ~dtor (assumes control of the stream) use only with proper ostream (eg: fstream), not (cout, cerr).
|
|
Update the ostream without overwriting the delete_ostream_ flag.
|
|
Get the result of the operation status (by convention, -1 means error).
|
|
Set the result of the operation status (by convention, -1 means error).
|
|
Initialize the ACE logging facility. Supplies the program name that is available to each logging message call. Default arguments set up logging to STDERR only.
|
|
|
|
Set the ACE_Log_Priority mask, returns original mask.
|
|
Get the current ACE_Log_Priority mask.
|
|
Returns the current program name used for logging.
|
|
Release the internal lock.
|
|
Get the field that indicates whether interrupted calls should be restarted.
|
|
Set the field that indicates whether interrupted calls should be restarted.
|
|
Set the line number, file name, operational status, error number, restart flag, ostream, and the callback object. This combines all the other set methods into a single method. |
|
Enable the bits in the logger's options flags.
|
|
Start tracing status on a per-thread basis...
|
|
Stop tracing status on a per-thread basis...
|
|
Call after doing a
|
|
Decouple the OS layer from the ACE_Log_Msg layer.
|
|
Set the TSS thread descriptor. This method will call td->acquire_release to block execution until this call return. |
|
Get the TSS thread descriptor.
|
|
Return the TSS singleton thread descriptor.
|
|
Get trace active status.
|
|
Set trace active status.
|
|
Set trace depth.
|
|
Get trace depth.
|
|
Query tracing status on a per-thread basis...
|
|
Declare the dynamic allocation hooks.
|
|
Anonymous struct since there will only be one instance. This struct keeps information stored away in case we actually end up calling log() if the log priority is correct.
|
|
Priority mask to use for each new instance.
|
|
Are we deleting this ostream?
|
|
Type of error that occurred (see <sys/errno.h>).
|
|
|
|
File where the error occurred.
|
|
Options flags.
|
|
Number of existing ACE_Log_Msg instances; when 0, delete program/host names.
|
|
|
|
|
|
Line number where the error occurred.
|
|
Name of the local host (used when printing messages).
|
|
The log message, which resides in thread-specific storage. Note that only the current log message is stored here -- it will be overwritten by the subsequent call to log().
|
|
The callback object.
|
|
Offset of msg_[].
|
|
|
|
The ostream where logging messages can be written.
|
|
Process id of the current process.
|
|
Keeps track of all the per-thread ACE_Log_Priority values that are currently enabled. Default is for all logging priorities to be disabled. |
|
Initial value: LM_SHUTDOWN | LM_TRACE | LM_DEBUG | LM_INFO | LM_NOTICE | LM_WARNING | LM_STARTUP | LM_ERROR | LM_CRITICAL | LM_ALERT | LM_EMERGENCY Default is for all logging priorities to be enabled. |
|
Records the program name.
|
|
Indicates whether we should restart system calls that are interrupted.
|
|
Status of operation (-1 means failure, >= 0 means success).
|
|
If we're running in the context of an ACE_Thread_Manager this will point to the thread descriptor adapter which holds the thread descriptor of the thread. This can be used to repidly access all thread data kept in ACE_Thread_Descriptor. |
|
Are we already within an ACE_Trace constructor call?
|
|
Depth of the nesting for printing traces.
|
|
Are we allowing tracing in this thread?
|