Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / examples / Logging / Logger_i.h
blob2b94f5ab540744efc55caa89d05938d82e5e11ae
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Logger_i.h
7 * @author Marina Spivak <marina@cs.wustl.edu>
8 * @author Sergio Flores-Gaitan <sergio@cs.wustl.edu>
9 * @author and Matthew Braun <mjb2@cec.wustl.edu>
11 //=============================================================================
14 #ifndef TAO_ORBSVCS_LOGGER_I_H
15 #define TAO_ORBSVCS_LOGGER_I_H
17 #include "LoggerS.h"
18 #include "ace/Hash_Map_Manager.h"
19 #include "ace/SString.h"
20 #include "ace/Null_Mutex.h"
22 /**
23 * @class Logger_i
25 * @brief Used to log messages to a logging server.
27 class Logger_i : public virtual POA_Logger
29 public:
30 /// constructor
31 Logger_i (const char* name);
33 /// destructor
34 virtual ~Logger_i (void);
36 /// Writes the <log_rec> to the standard output.
37 virtual void log (const Logger::Log_Record &log_rec);
39 /// Writes the <log_rec> to the standard output with the given
40 /// verbosity level
41 virtual void logv (const Logger::Log_Record &log_rec,
42 Logger::Verbosity_Level verbosity);
44 /// Writes the <log_rec> to the standard output.
45 virtual void log_twoway (const Logger::Log_Record &log_rec);
47 /// Writes the <log_rec> to the standard output with the given
48 /// verbosity level
49 virtual void logv_twoway (const Logger::Log_Record &log_rec,
50 Logger::Verbosity_Level verbosity);
52 /// Sets the verbosity level. Valid values are {VERBOSE, VERBOSE_LITE
53 /// and SILENT}. Defaults to VERBOSE
54 void verbosity (Logger::Verbosity_Level level);
56 private:
57 /// Converts the IDL defined <Log_Priority> enum type to the
58 /// <ACE_Log_Priority> enum type.
59 ACE_Log_Priority priority_conversion (Logger::Log_Priority priority);
61 /**
62 * Converts the IDL defined <Verbosity_Level> enum type to a u_long,
63 * which is used by the <ACE_Log_Record> to distinguish the
64 * level of verbosity.
66 u_long verbosity_conversion (Logger::Verbosity_Level verbosity_level);
68 /// Logger identification.
69 char *name_;
71 /// Keeps track of what our current verbosity level is. This can be
72 /// reset by the client to a new value at any point.
73 Logger::Verbosity_Level verbosity_level_;
76 /**
77 * @class Logger_Factory_i
79 * @brief Create a <Logger> of type <name>.
81 class Logger_Factory_i : public virtual POA_Logger_Factory
83 public:
84 /// Constructor.
85 Logger_Factory_i (void);
87 /// Destructor.
88 ~Logger_Factory_i (void);
90 /**
91 * This function returns a logger with name <name>. If <name> is
92 * unique, a new logger is created; else, a previously created
93 * logger of name <name> is returned
95 virtual Logger_ptr make_logger (const char *name);
97 private:
98 /**
99 * Calls to <make_logger> will create a new instance of <Logger> and
100 * bind into the hash map manager if <name> is unique, else it will
101 * return a previously bound entry.
103 ACE_Hash_Map_Manager<ACE_CString, Logger_i *, ACE_Null_Mutex> hash_map_;
106 #endif /* TAO_ORBSVCS_LOGGER_I_H */