#include <Logger_Impl.h>
Inheritance diagram for ASSA::Logger_Impl:
Public Member Functions | |
Logger_Impl () | |
virtual | ~Logger_Impl () |
void | enable_group (Group g_) |
void | disable_group (Group g_) |
void | enable_groups (u_long g_) |
void | disable_groups (u_long g_) |
void | enable_all_groups (void) |
void | disable_all_groups (void) |
bool | group_enabled (Group g_) const |
void | enable_timestamp (void) |
void | disable_timestamp (void) |
bool | timestamp_enabled (void) const |
void | set_timezone (int zone_) |
void | set_indent_step (u_short step_) |
u_short | get_indent_step (void) const |
virtual int | log_open (u_long groups_) |
Open StdErr Logger. | |
virtual int | log_open (const char *logfname_, u_long groups_, u_long maxsize_) |
Open File Logger. | |
virtual int | log_open (const char *appname_, const char *logfname_, u_long groups_, u_long maxsize_, Reactor *reactor_) |
Open connection with Log Server. | |
virtual int | log_close (void)=0 |
virtual void | log_resync (void) |
virtual int | log_msg (Group g_, size_t indent_level_, const string &func_name_, size_t expected_sz_, const char *fmt_, va_list)=0 |
virtual int | log_func (Group g_, size_t indent_level_, const string &func_name_, marker_t type_)=0 |
Static Public Attributes | |
static const unsigned int | LOGGER_MAXLINE = 6660 |
Maximum length of the formatted message. | |
Protected Member Functions | |
virtual u_short | add_timestamp (ostream &sink_) |
virtual u_short | indent_func_name (ostream &sink_, const string &funcname_, size_t indent_level_, marker_t type_) |
char * | format_msg (size_t expected_sz_, const char *fmt_, va_list vap_, bool &release_) |
Format and put the message in the buffer. | |
Protected Attributes | |
u_short | m_indent_step |
Indentation step. | |
u_long | m_groups |
Enabled groups. | |
string | m_logfname |
Log file name. | |
bool | m_tmflg |
Timestamp on/off flag. | |
int | m_tz |
Timezone: 0-GMT, 1-Local. | |
Static Protected Attributes | |
static char | m_msgbuf [LOGGER_MAXLINE] |
Static buffer for formatted message. |
Definition at line 139 of file Logger_Impl.h.
|
Definition at line 251 of file Logger_Impl.h. 00252 : m_indent_step (1), 00253 m_groups (0), 00254 m_tmflg (false), 00255 m_tz (1) 00256 { 00257 /* no-op */ 00258 }
|
|
Definition at line 151 of file Logger_Impl.h.
|
|
Definition at line 32 of file Logger_Impl.cpp. References ASSA::TimeVal::fmtString(), ASSA::TimeVal::gettimeofday(), m_tz, ASSA::TimeVal::msec(), timestamp_enabled(), and ASSA::TimeVal::tz(). Referenced by ASSA::StdOutLogger::log_func(), ASSA::RemoteLogger::log_func(), ASSA::FileLogger::log_func(), ASSA::StdOutLogger::log_msg(), ASSA::RemoteLogger::log_msg(), and ASSA::FileLogger::log_msg(). 00033 { 00034 /*--- 'DD/MM/CC HH:MM:SS.MMMM ' - 23 chars ---*/ 00035 u_short bytecount = 0; 00036 00037 if (timestamp_enabled ()) { 00038 TimeVal tv = TimeVal::gettimeofday (); 00039 tv.tz (m_tz); 00040 sink_ << tv.fmtString ("%m/%d/%Y %H:%M:%S") << '.'; 00041 char oldfill = sink_.fill('0'); 00042 sink_ << std::setw (3) << (tv.msec () % 1000000)/1000 << ' '; 00043 sink_.fill (oldfill); 00044 bytecount = 23; 00045 } 00046 return bytecount; 00047 }
|
|
Definition at line 160 of file Logger_Impl.h. References m_groups. Referenced by ASSA::Logger::disable_all_groups(). 00160 { m_groups = 0; }
|
|
Definition at line 154 of file Logger_Impl.h. References m_groups. Referenced by ASSA::Logger::disable_group(). 00154 { m_groups &= ~g_; }
|
|
Definition at line 157 of file Logger_Impl.h. References m_groups. Referenced by ASSA::Logger::disable_groups(). 00157 { m_groups &= ~g_; }
|
|
Definition at line 165 of file Logger_Impl.h. References m_tmflg. Referenced by ASSA::Logger::disable_timestamp(). 00165 { m_tmflg = false; }
|
|
Definition at line 159 of file Logger_Impl.h. References ASSA::ALL, and m_groups. Referenced by ASSA::Logger::enable_all_groups().
|
|
Definition at line 153 of file Logger_Impl.h. References m_groups. Referenced by ASSA::Logger::enable_group(). 00153 { m_groups |= g_; }
|
|
Definition at line 156 of file Logger_Impl.h. References m_groups. Referenced by ASSA::Logger::enable_groups(). 00156 { m_groups |= g_; }
|
|
Definition at line 164 of file Logger_Impl.h. References m_tmflg. Referenced by ASSA::Logger::enable_timestamp(). 00164 { m_tmflg = true; }
|
|
Format and put the message in the buffer. If expected size is smaller then LOGGER_MAXLINE, formatted message is written to the static buffer and release_ is set to false. Otherwise, this function allocates a buffer on the heap big enough to hold the message and set release_ to true. In this case caller is responsible for releasing the memory by calling delete [].
Definition at line 83 of file Logger_Impl.cpp. References ASSA::flush(), LOGGER_MAXLINE, and m_msgbuf. Referenced by ASSA::StdOutLogger::log_msg(), ASSA::RemoteLogger::log_msg(), and ASSA::FileLogger::log_msg(). 00087 { 00088 char* msg = m_msgbuf; // Use internal buffer 00089 int ret = 0; 00090 00091 release_ = false; 00092 expected_sz_++; // Expected size includes '\0' 00093 00094 if (expected_sz_ >= LOGGER_MAXLINE) { // Allocate temporary buffer 00095 msg = new char [expected_sz_]; 00096 release_ = true; 00097 } 00098 00099 ret = ::vsnprintf (msg, expected_sz_, fmt_, vap_); 00100 #if NEVER 00101 if (ret < 0) { 00102 std::cout << "Logger_Impl: format_mg(expected_sz=" << expected_sz_ 00103 << ")=-1 failed! errno=" << errno << " (" 00104 << strerror(errno) << "\n" << std::flush; 00105 } 00106 #endif 00107 00108 return (ret < 0 ? NULL : msg); 00109 }
|
|
Definition at line 170 of file Logger_Impl.h. References m_indent_step. 00170 { return m_indent_step; }
|
|
Definition at line 162 of file Logger_Impl.h. References m_groups. Referenced by ASSA::Logger::group_enabled(), ASSA::StdOutLogger::log_func(), ASSA::RemoteLogger::log_func(), ASSA::FileLogger::log_func(), ASSA::StdOutLogger::log_msg(), ASSA::RemoteLogger::log_msg(), and ASSA::FileLogger::log_msg(). 00162 { return (m_groups & g_); }
|
|
Definition at line 51 of file Logger_Impl.cpp. References m_indent_step. Referenced by ASSA::StdOutLogger::log_func(), ASSA::RemoteLogger::log_func(), ASSA::FileLogger::log_func(), ASSA::StdOutLogger::log_msg(), ASSA::RemoteLogger::log_msg(), and ASSA::FileLogger::log_msg(). 00055 { 00056 u_short bytecount = 0; 00057 00058 if (func_name_.size ()) { 00059 u_int i = 1; 00060 while (i < indent_level_) { 00061 sink_ << '|'; 00062 for (u_short j = 0; j < m_indent_step-1; j++) { 00063 sink_ << ' '; 00064 } 00065 i++; 00066 } 00067 if (type_ == FUNC_ENTRY) { 00068 sink_ << '/' << func_name_ << " "; 00069 } 00070 else if (type_ == FUNC_EXIT) { 00071 sink_ << '\\' << func_name_ << " "; 00072 } 00073 else if (type_ == FUNC_MSG) { 00074 sink_ << '[' << func_name_ << "] "; 00075 } 00076 bytecount += indent_level_ * m_indent_step + func_name_.size () + 3; 00077 } 00078 return bytecount; 00079 }
|
|
Implemented in ASSA::FileLogger, ASSA::RemoteLogger, and ASSA::StdOutLogger. Referenced by ASSA::Logger::log_close(). |
|
Implemented in ASSA::FileLogger, ASSA::RemoteLogger, and ASSA::StdOutLogger. Referenced by ASSA::Logger::log_func(). |
|
Implemented in ASSA::FileLogger, ASSA::RemoteLogger, and ASSA::StdOutLogger. Referenced by ASSA::Logger::log_msg(). |
|
Open connection with Log Server.
Reimplemented in ASSA::RemoteLogger. Definition at line 280 of file Logger_Impl.h.
|
|
Open File Logger.
Reimplemented in ASSA::FileLogger. Definition at line 270 of file Logger_Impl.h.
|
|
Open StdErr Logger.
Reimplemented in ASSA::StdOutLogger. Definition at line 262 of file Logger_Impl.h. Referenced by ASSA::Logger::log_open().
|
|
Reimplemented in ASSA::FileLogger, ASSA::RemoteLogger, and ASSA::StdOutLogger. Definition at line 188 of file Logger_Impl.h. Referenced by ASSA::Logger::log_resync().
|
|
Definition at line 169 of file Logger_Impl.h. References m_indent_step. 00169 { m_indent_step = step_; }
|
|
Definition at line 167 of file Logger_Impl.h. References m_tz. Referenced by ASSA::Logger::set_timezone(). 00167 { m_tz = zone_; }
|
|
Definition at line 166 of file Logger_Impl.h. References m_tmflg. Referenced by add_timestamp(), and ASSA::Logger::timestamp_enabled(). 00166 { return m_tmflg; }
|
|
Maximum length of the formatted message. The size is selected based on the maximum number of bytes transmitted through Socketbuf which is 1416. This is at most the bytes dumped with MemDump - (1416/16 + 2) * 74 = 6660. See MemDump.cpp comments for details. Definition at line 147 of file Logger_Impl.h. Referenced by format_msg(). |
|
Enabled groups.
Definition at line 237 of file Logger_Impl.h. Referenced by disable_all_groups(), disable_group(), disable_groups(), ASSA::FileLogger::dump(), enable_all_groups(), enable_group(), enable_groups(), group_enabled(), ASSA::FileLogger::log_close(), ASSA::StdOutLogger::log_open(), ASSA::RemoteLogger::log_open(), and ASSA::FileLogger::log_open(). |
|
Indentation step.
Definition at line 234 of file Logger_Impl.h. Referenced by ASSA::FileLogger::dump(), get_indent_step(), indent_func_name(), and set_indent_step(). |
|
Log file name.
Definition at line 240 of file Logger_Impl.h. Referenced by ASSA::FileLogger::dump(), ASSA::RemoteLogger::handle_close(), ASSA::FileLogger::handle_rollover(), ASSA::FileLogger::log_close(), ASSA::RemoteLogger::log_open(), and ASSA::FileLogger::log_open(). |
|
Static buffer for formatted message.
Definition at line 231 of file Logger_Impl.h. Referenced by format_msg(). |
|
Timestamp on/off flag.
Definition at line 243 of file Logger_Impl.h. Referenced by disable_timestamp(), ASSA::FileLogger::dump(), enable_timestamp(), and timestamp_enabled(). |
|
Timezone: 0-GMT, 1-Local.
Definition at line 246 of file Logger_Impl.h. Referenced by add_timestamp(), and set_timezone(). |