51 BESLog *BESLog::_instance = 0 ;
82 string err = (string)
"BES Fatal: unable to determine log file name."
83 +
" The key BES.LogName has multiple values" ;
87 if( _file_name ==
"" )
89 string err = (string)
"BES Fatal: unable to determine log file name."
90 +
" Please set BES.LogName in your initialization file" ;
94 _file_buffer =
new ofstream( _file_name.c_str(), ios::out | ios::app ) ;
95 if( !(*_file_buffer) )
97 string err = (string)
"BES Fatal; cannot open log file "
105 if( verbose ==
"YES" || verbose ==
"Yes" || verbose ==
"yes" )
117 _file_buffer->close();
131 const time_t sctime=time(NULL);
132 const struct tm *sttime=localtime(&sctime);
134 strftime(zone_name,
sizeof(zone_name),
"%Z", sttime);
135 char *b=asctime(sttime);
136 (*_file_buffer)<<
"["<<zone_name<<
" ";
137 for (
register int j=0; b[j]!=
'\n'; j++)
138 (*_file_buffer)<<b[j];
139 pid_t thepid = getpid() ;
140 (*_file_buffer)<<
" id: "<<thepid<<
"] ";
154 (*_file_buffer) << s;
169 (*_file_buffer) << s;
185 (*_file_buffer) << val;
187 (*_file_buffer) <<
"NULL" ;
205 (*_file_buffer) << val;
207 (*_file_buffer) <<
"NULL" ;
222 (*_file_buffer) << val;
237 (*_file_buffer) << val;
252 (*_file_buffer) << val;
267 (*_file_buffer) << val;
282 (*_file_buffer) << val;
298 (*_file_buffer) << val ;
314 (*_file_buffer)<<val;
329 << (
void *)
this <<
")" << endl ;
332 if( _file_buffer && *_file_buffer )
exception thrown if an internal error is found and is fatal to the BES
~BESLog()
Cleans up the logging mechanism.
ostream &(* p_ostream_manipulator)(ostream &)
Defines a data type p_ostream_manipulator "pointer to function that takes ostream& and returns ostrea...
BESLog & operator<<(string &)
Overloaded inserter that writes the specified string.
static ostream & LMarg(ostream &strm)
void get_value(const string &s, string &val, bool &found)
Retrieve the value of a given key, if set.
virtual void dump(ostream &strm) const
dumps information about this object
void dump_time()
Protected method that dumps the date/time to the log file.
BESLog()
constructor that sets up logging for the application.
Provides a mechanism for applications to log information to an external file.
static BESKeys * TheKeys()