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);
void clr_flags (u_long f);
u_long flags (void);

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);
int release (void);
void sync (const char *program_name);

Set/get methods. Note that these are non-static and thus will

be thread-specific.
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);

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);
u_long priority_mask (u_long);
pid_t getpid (void) const;

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
    );
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;

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_;
static const char *local_host_;
static pid_t pid_;
static u_long flags_;
static int msg_off_;

AUTHOR

Doug Schmidt

LIBRARY

ace