NAME
ACE_Log_Msg -
Provides a variable length argument message logging
abstraction.
SYNOPSIS
#include <ace/Log_Msg.h>
class ACE_Log_Msg
{
public:
SILENT = 020 }; static ACE_Log_Msg *instance (void);
ACE_Log_Msg (void);
int open (
const char *prog_name,
u_long options_flags = ACE_Log_Msg::STDERR,
const char *logger_key = 0
);
void set_flags (u_long f);
void clr_flags (u_long f);
u_long flags (void);
int acquire (void);
int release (void);
void sync (const char *program_name);
void op_status (int status);
int op_status (void);
void errnum (int);
int errnum (void);
void linenum (int);
int linenum (void);
void file (const char *);
const char *file (void);
void msg (char *);
char *msg (void);
void restart (int);
int restart (void);
void msg_ostream (ostream *);
ostream *msg_ostream (void);
int inc (void);
int dec (void);
int trace_active (void);
void trace_active (int value);
ACE_Thread_State *thr_state (void);
void thr_state (ACE_Thread_State *);
ACE_hthread_t *thr_handle (void);
void thr_handle (ACE_hthread_t *);
void stop_tracing (void);
void start_tracing (void);
int tracing_enabled (void);
u_long priority_mask (void);
u_long priority_mask (u_long);
pid_t getpid (void) const;
const char *local_host (void) const;
void local_host (const char *);
void set (
const char *file,
int line,
int op_status = -1,
int errnum = 0,
int restart = 1,
ostream *os = 0
);
ssize_t log (ACE_Log_Priority priority, const char *format, ...);
ssize_t log (
const char *format,
ACE_Log_Priority priority,
va_list argp
);
int log_hexdump (
ACE_Log_Priority log_priority,
char *buffer,
int size
);
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
private:
int status_;
int errnum_;
int linenum_;
char file_[MAXNAMELEN];
char msg_[ACE_Log_Record::MAXLOGMSGLEN];
int restart_;
ostream *ostream_;
int trace_depth_;
int trace_active_;
int tracing_enabled_;
ACE_Thread_State *thr_state_;
ACE_hthread_t *thr_handle_;
u_long priority_mask_;
static const char *program_name_;
static const char *local_host_;
static pid_t pid_;
static u_long flags_;
static int msg_off_;
};
DESCRIPTION
This class is very flexible since it allows formatted error
messages to be printed in a thread-safe manner to stderr or a
distributed logger. Moreover, the message is kept in a
thread-specific storage location, which can be used to
communicate errors between framework methods and callers.
Set/get the options flags.
void set_flags (u_long f);
Enable the bits in the logger's options flags.
void clr_flags (u_long f);
Disable the bits in the logger's options flags.
u_long flags (void);
Return the bits in the logger's options flags.
Operations that allow applications to acquire and release the
synchronization lock used internally by the ACE_Log_Msg
implementation. This allows applications to hold the lock
atomically over a number of calls to ACE_Log_Msg.
int acquire (void);
Acquire the internal lock.
int release (void);
Release the internal lock.
void sync (const char *program_name);
Call after doing a fork() to resynchronize the PID and
PROGRAM_NAME variables.
Set/get methods. Note that these are non-static and thus will
be thread-specific.
void op_status (int status);
Set the result of the operation status (by convention, -1 means error).
int op_status (void);
Get the result of the operation status (by convention, -1 means error).
void errnum (int);
Set the value of the errnum (by convention this corresponds to errno).
int errnum (void);
Get the value of the errnum (by convention this corresponds to errno).
void linenum (int);
Set the line number where an error occurred.
int linenum (void);
Get the line number where an error occurred.
void file (const char *);
Set the file name where an error occurred.
const char *file (void);
Get the file name where an error occurred.
void msg (char *);
Set the message that describes what type of error occurred.
char *msg (void);
Get the message that describes what type of error occurred.
void restart (int);
Set the field that indicates whether interrupted calls should be
restarted.
int restart (void);
Get the field that indicates whether interrupted calls should be
restarted.
void msg_ostream (ostream *);
Set the ostream that is used to print error messages.
ostream *msg_ostream (void);
Get the ostream that is used to print error messages.
Nesting depth increment and decrement.
int inc (void);
int dec (void);
Get/set trace active status.
int trace_active (void);
void trace_active (int value);
Get/set the current thread state.
ACE_Thread_State *thr_state (void);
void thr_state (ACE_Thread_State *);
Get/set the current thread ACE_hthread_t.
ACE_hthread_t *thr_handle (void);
void thr_handle (ACE_hthread_t *);
Stop/start/query tracing status on a per-thread basis...
void stop_tracing (void);
void start_tracing (void);
int tracing_enabled (void);
Get/set the priority mask.
u_long priority_mask (void);
Get the current ACE_Log_Priority mask.
u_long priority_mask (u_long);
Set the ACE_Log_Priority mask, returns original mask.
pid_t getpid (void) const;
Optimize reading of the pid (avoids a system call if the
value is cached...).
Set/get the name of the local host.
const char *local_host (void) const;
void local_host (const char *);
void set (
const char *file,
int line,
int op_status = -1,
int errnum = 0,
int restart = 1,
ostream *os = 0
);
Set the line number, file name, operational status, error number,
restart flag, and ostream. This combines all the other set
methods into a single method.
ssize_t log (ACE_Log_Priority priority, const char *format, ...);
Format a message to the thread-safe ACE logging mechanism. Valid
options (prefixed by '%', as in printf format strings) include:
'a': exit the program at this point (var-argument is the exit status!)
'c': print a character
'i', 'd': print a decimal number
'e', 'E', 'f', 'F', 'g', 'G': print a double
'l', print line number where an error occurred.
'N': print file name where the error occurred.
'n': print the name of the program (or "unknown" if not set)
'o': print as an octal number
'P': print out the current process id
'p': print out the appropriate errno value from sys_errlist
'r': call the function pointed to by the corresponding argument
'R': print return status
'S': print out the appropriate _sys_siglist entry corresponding to var-argument.
's': print out a character string
'T': print timestamp in hour:minute:sec:usec format.
't': print thread id (1 if single-threaded)
'u': print as unsigned int
'X', 'x': print as a hex number
'%': print out a single percent sign, '%'
ssize_t log (
const char *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.
int log_hexdump (
ACE_Log_Priority log_priority,
char *buffer,
int size
);
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.
void dump (void) const;
Dump the state of an object.
ACE_ALLOC_HOOK_DECLARE;
Declare the dynamic allocation hooks.
The following fields are *not* kept in thread-specific storage
since we only want one instance for the entire process!
static const char *program_name_;
Records the program name.
static const char *local_host_;
Name of the local host (used when printing messages).
static pid_t pid_;
Process id of the current process.
static u_long flags_;
static int msg_off_;
AUTHOR
Doug Schmidt
LIBRARY
ace