79 d_flushed(1), d_file_buffer(0), d_suspended(0), d_verbose(false), d_use_local_time(false), d_use_unix_time(false)
88 msg << prolog <<
"ERROR - Caught BESInternalFatalError! Will re-throw. Message: " << bife.
get_message() <<
" File: " << bife.
get_file() <<
" Line: " << bife.
get_line() << endl;
89 BESDEBUG(MODULE,msg.str());
95 msg << prolog <<
"FATAL ERROR: Caught unknown exception! Unable to determine log file name." << endl;
96 BESDEBUG(MODULE,msg.str());
107 BESDEBUG(MODULE, prolog <<
"d_use_local_time: " << (d_use_local_time?
"true":
"false") << endl);
111 err << prolog <<
"FATAL ERROR: Caught unknown exception. Failed to read the value of BES.LogTimeLocal" << endl;
112 BESDEBUG(MODULE,err.str());
113 cerr << err.str() << endl;
117 if (d_file_name.empty()) {
119 err << prolog <<
"FATAL ERROR: unable to determine log file name. ";
120 err <<
"Please set BES.LogName in your initialization file" << endl;
121 BESDEBUG(MODULE,err.str());
122 cerr << err.str() << endl;
126 d_file_buffer =
new ofstream(d_file_name.c_str(), ios::out | ios::app);
127 if (!(*d_file_buffer)) {
129 err << prolog <<
"BES Fatal; cannot open log file " + d_file_name +
"." << endl;
130 BESDEBUG(MODULE,err.str());
131 cerr << err.str() << endl;
139 BESDEBUG(MODULE, prolog <<
"d_verbose: " << (d_verbose?
"true":
"false") << endl);
145 BESDEBUG(MODULE, prolog <<
"d_use_unix_time: " << (d_use_unix_time?
"true":
"false") << endl);
169#ifdef ISO8601_TIME_IN_LOGS
173 char buf[
sizeof "YYYY-MM-DDTHH:MM:SS zones"];
175 (*d_file_buffer) << now;
179 if (!d_use_local_time){
180 gmtime_r(&now, &date_time);
183 localtime_r(&now, &date_time);
185 (void)strftime(buf,
sizeof buf,
"%FT%T %Z", &date_time);
186 (*d_file_buffer) << buf;
189 const time_t sctime = time(NULL);
190 const struct tm *sttime = localtime(&sctime);
192 strftime(zone_name,
sizeof(zone_name),
"%Z", sttime);
193 char *b = asctime(sttime);
195 (*d_file_buffer) << zone_name <<
" ";
196 for (
register int j = 0; b[j] !=
'\n'; j++)
197 (*d_file_buffer) << b[j];
200 (*d_file_buffer) << mark << getpid() << mark;
384 strm << BESIndent::LMarg <<
"BESLog::dump - (" << (
void *)
this <<
")" << endl;
386 strm << BESIndent::LMarg <<
"log file: " << d_file_name << endl;
387 if (d_file_buffer && *d_file_buffer) {
388 strm << BESIndent::LMarg <<
"log is valid" << endl;
391 strm << BESIndent::LMarg <<
"log is NOT valid" << endl;
393 strm << BESIndent::LMarg <<
"is verbose: " << d_verbose << endl;
394 strm << BESIndent::LMarg <<
"is flushed: " << d_flushed << endl;
395 strm << BESIndent::LMarg <<
"is suspended: " << d_suspended << endl;
396 BESIndent::UnIndent();