10#if defined(__FastCaloSimStandAlone__)
14 level = (
level >= MSG::NUM_LEVELS) ? MSG::ALWAYS
17 m_level = MSG::Level(
level);
24 return this->
stream(lvl,
"", -1);
32MsgStream &MLogging::stream(MSG::Level lvl, std::string
file,
int line)
const {
35 return *m_null_msg_ptr;
37 if (this->streamerNeedStart(lvl,
file)) {
39 if (this->streamerInLine())
40 std::cout << this->streamerEndLine(lvl);
42 this->streamerInLine(
true);
49 if (lvl == MSG::VERBOSE || lvl == MSG::DEBUG)
50 return m_level <= lvl;
56void MLogging::print(MSG::Level lvl, std::string
file,
int line,
57 std::string message)
const {
64std::string MLogging::streamerEndLine(MSG::Level lvl)
const {
66 m_streamer_in_line =
false;
73void MLogging::streamerInLine(
bool is_in_line)
const {
74 m_streamer_in_line = is_in_line;
78bool MLogging::streamerNeedStart(MSG::Level lvl, std::string
file)
const {
80 if (lvl == m_streamer_has_lvl &&
file == m_streamer_from_file &&
84 m_streamer_from_file =
file;
85 m_streamer_has_lvl = lvl;
106 lvl = (lvl >= MSG::NUM_LEVELS) ? MSG::ALWAYS
107 : (lvl < MSG::NIL) ? MSG::NIL
120 auto last_slash =
file.find_last_of(
'/');
121 int path_len = last_slash == std::string::npos ? 0 : last_slash;
122 int trim_point = path_len;
123 int total_len =
file.length();
124 if (total_len - path_len > col1_len)
125 trim_point = total_len - col1_len;
126 std::string trimmed_name =
file.substr(trim_point);
127 const char *LevelNames[MSG::NUM_LEVELS] = {
128 "NIL",
"VERBOSE",
"DEBUG",
"INFO",
"WARNING",
"ERROR",
"FATAL",
"ALWAYS"};
129 std::string
level = LevelNames[lvl];
130 std::string level_string = std::string(
"(") +
level +
") ";
131 std::stringstream output;
132 output << std::setw(col1_len) << std::right << trimmed_name <<
":"
133 << std::setw(col2_len) << std::left << line << std::setw(col3_len)
134 << std::right << level_string;
bool msgLvl(const MSG::Level lvl) const
Check whether the logging system is active at the provided verbosity level.
MLogging(const std::string &name="ISF_FastCaloSimEvent")
Constructor.
virtual ~MLogging()
Destructor:
virtual void setLevel(MSG::Level lvl)
Update outputlevel.
MLogging & operator=(const MLogging &rhs)
static std::string startMsg(MSG::Level lvl, const std::string &file, int line)
Make a message to decorate the start of logging.
std::string m_nm
Message source name.
MsgStream & msg() const
Return a stream for sending messages directly (no decoration)
MSG::Level level() const
Retrieve output level.