52#define REQUEST_LOG(x) do { BESLog::TheLog()->trace_request(x, __FILE__ ,__LINE__); } while(0)
53#define INFO_LOG(x) do { BESLog::TheLog()->trace_info(x, __FILE__ ,__LINE__); } while(0)
54#define ERROR_LOG(x) do { BESLog::TheLog()->trace_error(x, __FILE__ ,__LINE__); } while(0)
55#define VERBOSE(x) do {if (BESLog::TheLog()->is_verbose()) BESLog::TheLog()->trace_verbose(x, __FILE__, __LINE__; } while(0)
56#define TIMING_LOG(x) do { BESLog::TheLog()->trace_timing(x, __FILE__ ,__LINE__); } while(0)
58#define REQUEST_LOG(x) do { BESLog::TheLog()->request(x); } while(0)
59#define INFO_LOG(x) do { BESLog::TheLog()->info(x); } while(0)
60#define ERROR_LOG(x) do { BESLog::TheLog()->error(x); } while(0)
61#define VERBOSE(x) do {if (BESLog::TheLog()->is_verbose()) BESLog::TheLog()->verbose(x); } while(0)
62#define TIMING_LOG(x) do { BESLog::TheLog()->timing(x); } while(0)
116 static BESLog * d_instance;
118 std::ofstream *d_file_buffer =
nullptr;
119 std::string d_file_name;
120 std::string d_instance_id =
"-";
121 std::string d_pid =
"-";
122 std::string request_id{
"BESLog-NotYetSet"};
123 std::string d_log_record_prolog_base;
126 bool d_verbose =
false;
129 bool d_use_local_time =
false;
132 bool d_use_unix_time =
false;
134 const char* REQUEST_LOG_TYPE_KEY =
"request";
135 const char* INFO_LOG_TYPE_KEY =
"info";
136 const char* ERROR_LOG_TYPE_KEY =
"error";
137 const char* VERBOSE_LOG_TYPE_KEY =
"verbose";
138 const char* TIMING_LOG_TYPE_KEY =
"timing";
146 void log_record(
const std::string &record_type,
const std::string &msg)
const;
147 void trace_log_record(
const std::string &record_type,
const std::string &msg,
const std::string &file,
int line)
const;
152 const static std::string mark;
198 void info(
const std::string &msg)
const {
205 void error(
const std::string &msg)
const {
221 void timing(
const std::string &msg)
const {
228 void trace_request(
const std::string &msg,
const std::string &file,
int line)
const {
235 void trace_info(
const std::string &msg,
const std::string &file,
int line)
const {
242 void trace_error(
const std::string &msg,
const std::string &file,
int line)
const {
249 void trace_verbose(
const std::string &msg,
const std::string &file,
int line)
const {
258 void trace_timing(
const std::string &msg,
const std::string &file,
int line)
const {
264 std::string get_request_id()
const {
return request_id;}
266 void dump(std::ostream &strm)
const override;
273 std::ostream *get_log_ostream()
const {
274 return d_file_buffer;
bool is_verbose() const
Returns true if verbose logging is requested.
void set_request_id(const std::string &id)
Sets the current request id (cached in BESLog) to id.
pid_t update_pid()
Update the d_pid and the d_log_record_prolog_base values.
void log_record(const std::string &record_type, const std::string &msg) const
Writes msg to a log record with type lrt.
void trace_info(const std::string &msg, const std::string &file, int line) const
Writes info msg to the log stream with FILE and LINE.
void trace_verbose(const std::string &msg, const std::string &file, int line) const
Writes verbose msg to the log stream with FILE and LINE, if verbose logging is enabled.
void trace_log_record(const std::string &record_type, const std::string &msg, const std::string &file, int line) const
Writes msg, file, and line to a trace log record with type lrt.
void verbose_on()
turn on verbose logging
void timing(const std::string &msg) const
Writes timing msg to the log stream.
std::string log_record_begin() const
Protected method that returns a string with the first fields of a log record.
void trace_request(const std::string &msg, const std::string &file, int line) const
Writes request msg to the log stream with FILE and LINE.
void error(const std::string &msg) const
Writes error msg to the log stream.
void trace_timing(const std::string &msg, const std::string &file, int line) const
Writes timing msg to the log stream with FILE and LINE.
void trace_error(const std::string &msg, const std::string &file, int line) const
Writes error msg to the log stream with FILE and LINE.
void dump(std::ostream &strm) const override
dumps information about this object
void verbose_off()
turns off verbose logging
void verbose(const std::string &msg) const
Writes verbose msg to the log stream, if verbose logging is enabled.
void request(const std::string &msg) const
Writes request msg to the log stream.
~BESLog() override
Cleans up the logging mechanism.
BESLog()
constructor that sets up logging for the application.
void info(const std::string &msg) const
Writes info msg to the log stream.
top level BES object to house generic methods