mirror of
https://github.com/FairRootGroup/FairLogger.git
synced 2025-10-15 17:41:44 +00:00
Compare commits
14 Commits
v1.10.2
...
d930187f4e
Author | SHA1 | Date | |
---|---|---|---|
|
d930187f4e | ||
|
b9469b8a26 | ||
|
f3d68fb4ba | ||
|
0ae9a697b4 | ||
|
fdbc047591 | ||
|
ea4067c474 | ||
|
067dcc0e26 | ||
|
0ab390c465 | ||
|
56b90a7445 | ||
|
7fc05f3808 | ||
|
d93fb0870b | ||
|
953eac19c8 | ||
|
9a6644c931 | ||
|
27040ea292 |
@@ -1,5 +1,5 @@
|
||||
################################################################################
|
||||
# Copyright (C) 2018-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# Copyright (C) 2018-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
@@ -7,7 +7,7 @@
|
||||
################################################################################
|
||||
|
||||
cmake_minimum_required(VERSION 3.9.4 FATAL_ERROR)
|
||||
cmake_policy(VERSION 3.9...3.19)
|
||||
cmake_policy(VERSION 3.9...3.30)
|
||||
|
||||
# Project ######################################################################
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
||||
@@ -54,7 +54,7 @@ add_library(FairLogger
|
||||
logger/Logger.cxx
|
||||
logger/Logger.h
|
||||
)
|
||||
target_compile_features(FairLogger PUBLIC cxx_std_14)
|
||||
target_compile_features(FairLogger PUBLIC cxx_std_17)
|
||||
|
||||
if(USE_BOOST_PRETTY_FUNCTION)
|
||||
target_link_libraries(FairLogger PUBLIC Boost::boost)
|
||||
|
10
Jenkinsfile
vendored
10
Jenkinsfile
vendored
@@ -62,8 +62,14 @@ pipeline{
|
||||
[os: 'fedora', ver: '32', arch: 'x86_64', compiler: 'gcc-10'],
|
||||
[os: 'fedora', ver: '33', arch: 'x86_64', compiler: 'gcc-10'],
|
||||
[os: 'fedora', ver: '34', arch: 'x86_64', compiler: 'gcc-11'],
|
||||
[os: 'macos', ver: '11', arch: 'x86_64', compiler: 'apple-clang-12'],
|
||||
[os: 'macos', ver: '11', arch: 'arm64', compiler: 'apple-clang-13'],
|
||||
[os: 'fedora', ver: '35', arch: 'x86_64', compiler: 'gcc-11'],
|
||||
[os: 'fedora', ver: '36', arch: 'x86_64', compiler: 'gcc-12'],
|
||||
[os: 'fedora', ver: '37', arch: 'x86_64', compiler: 'gcc-12'],
|
||||
[os: 'fedora', ver: '38', arch: 'x86_64', compiler: 'gcc-13'],
|
||||
[os: 'fedora', ver: '39', arch: 'x86_64', compiler: 'gcc-13'],
|
||||
[os: 'macos', ver: '13', arch: 'x86_64', compiler: 'apple-clang-15'],
|
||||
[os: 'macos', ver: '14', arch: 'x86_64', compiler: 'apple-clang-15'],
|
||||
[os: 'macos', ver: '14', arch: 'arm64', compiler: 'apple-clang-15'],
|
||||
])
|
||||
|
||||
parallel(builds)
|
||||
|
@@ -93,12 +93,14 @@ where severity level is one of the following:
|
||||
"debug2",
|
||||
"debug1",
|
||||
"debug",
|
||||
"detail",
|
||||
"info",
|
||||
"state",
|
||||
"warn",
|
||||
"important",
|
||||
"alarm",
|
||||
"error",
|
||||
"critical",
|
||||
"fatal",
|
||||
```
|
||||
|
||||
|
@@ -94,7 +94,7 @@ macro(set_fairlogger_defaults)
|
||||
endif()
|
||||
|
||||
# Handle C++ standard level
|
||||
set(PROJECT_MIN_CXX_STANDARD 14)
|
||||
set(PROJECT_MIN_CXX_STANDARD 17)
|
||||
if(CMAKE_CXX_STANDARD LESS PROJECT_MIN_CXX_STANDARD)
|
||||
message(FATAL_ERROR "A minimum CMAKE_CXX_STANDARD of ${PROJECT_MIN_CXX_STANDARD} is required.")
|
||||
endif()
|
||||
@@ -128,8 +128,8 @@ macro(set_fairlogger_defaults)
|
||||
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_LIBDIR}" isSystemDir)
|
||||
if("${isSystemDir}" STREQUAL "-1")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
list(APPEND CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-new-dtags")
|
||||
list(APPEND CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-new-dtags")
|
||||
string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--enable-new-dtags")
|
||||
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,--enable-new-dtags")
|
||||
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN/../${PROJECT_INSTALL_LIBDIR}")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../${PROJECT_INSTALL_LIBDIR}")
|
||||
|
@@ -1,11 +1,12 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014-2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* Copyright (C) 2014-2025 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
#include "Logger.h"
|
||||
#include <string_view>
|
||||
|
||||
#if FMT_VERSION < 60000
|
||||
#include <fmt/time.h>
|
||||
@@ -15,6 +16,7 @@
|
||||
|
||||
#include <cstdio> // printf
|
||||
#include <iostream>
|
||||
#include <iterator> // std::back_inserter
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -43,55 +45,59 @@ const string Logger::fProcessName = program_invocation_short_name;
|
||||
const string Logger::fProcessName = "?";
|
||||
#endif
|
||||
|
||||
const unordered_map<string, Verbosity> Logger::fVerbosityMap =
|
||||
const unordered_map<string_view, Verbosity> Logger::fVerbosityMap =
|
||||
{
|
||||
{ "veryhigh", Verbosity::veryhigh },
|
||||
{ "high", Verbosity::high },
|
||||
{ "medium", Verbosity::medium },
|
||||
{ "low", Verbosity::low },
|
||||
{ "verylow", Verbosity::verylow },
|
||||
{ "VERYHIGH", Verbosity::veryhigh },
|
||||
{ "HIGH", Verbosity::high },
|
||||
{ "MEDIUM", Verbosity::medium },
|
||||
{ "LOW", Verbosity::low },
|
||||
{ "VERYLOW", Verbosity::verylow },
|
||||
{ "user1", Verbosity::user1 },
|
||||
{ "user2", Verbosity::user2 },
|
||||
{ "user3", Verbosity::user3 },
|
||||
{ "user4", Verbosity::user4 }
|
||||
{ {"veryhigh"}, Verbosity::veryhigh },
|
||||
{ {"high"}, Verbosity::high },
|
||||
{ {"medium"}, Verbosity::medium },
|
||||
{ {"low"}, Verbosity::low },
|
||||
{ {"verylow"}, Verbosity::verylow },
|
||||
{ {"VERYHIGH"}, Verbosity::veryhigh },
|
||||
{ {"HIGH"}, Verbosity::high },
|
||||
{ {"MEDIUM"}, Verbosity::medium },
|
||||
{ {"LOW"}, Verbosity::low },
|
||||
{ {"VERYLOW"}, Verbosity::verylow },
|
||||
{ {"user1"}, Verbosity::user1 },
|
||||
{ {"user2"}, Verbosity::user2 },
|
||||
{ {"user3"}, Verbosity::user3 },
|
||||
{ {"user4"}, Verbosity::user4 }
|
||||
};
|
||||
|
||||
const unordered_map<string, Severity> Logger::fSeverityMap =
|
||||
const unordered_map<string_view, Severity> Logger::fSeverityMap =
|
||||
{
|
||||
{ "nolog", Severity::nolog },
|
||||
{ "NOLOG", Severity::nolog },
|
||||
{ "error", Severity::error },
|
||||
{ "ERROR", Severity::error },
|
||||
{ "alarm", Severity::alarm },
|
||||
{ "important", Severity::important },
|
||||
{ "warn", Severity::warn },
|
||||
{ "WARN", Severity::warn },
|
||||
{ "warning", Severity::warn },
|
||||
{ "WARNING", Severity::warn },
|
||||
{ "state", Severity::state },
|
||||
{ "STATE", Severity::state },
|
||||
{ "info", Severity::info },
|
||||
{ "INFO", Severity::info },
|
||||
{ "debug", Severity::debug },
|
||||
{ "DEBUG", Severity::debug },
|
||||
{ "debug1", Severity::debug1 },
|
||||
{ "DEBUG1", Severity::debug1 },
|
||||
{ "debug2", Severity::debug2 },
|
||||
{ "DEBUG2", Severity::debug2 },
|
||||
{ "debug3", Severity::debug3 },
|
||||
{ "DEBUG3", Severity::debug3 },
|
||||
{ "debug4", Severity::debug4 },
|
||||
{ "DEBUG4", Severity::debug4 },
|
||||
{ "trace", Severity::trace },
|
||||
{ "TRACE", Severity::trace }
|
||||
{ {"nolog"}, Severity::nolog },
|
||||
{ {"NOLOG"}, Severity::nolog },
|
||||
{ {"fatal"}, Severity::fatal },
|
||||
{ {"FATAL"}, Severity::fatal },
|
||||
{ {"critical"}, Severity::critical },
|
||||
{ {"error"}, Severity::error },
|
||||
{ {"ERROR"}, Severity::error },
|
||||
{ {"alarm"}, Severity::alarm },
|
||||
{ {"important"}, Severity::important },
|
||||
{ {"warn"}, Severity::warn },
|
||||
{ {"WARN"}, Severity::warn },
|
||||
{ {"warning"}, Severity::warn },
|
||||
{ {"WARNING"}, Severity::warn },
|
||||
{ {"state"}, Severity::state },
|
||||
{ {"STATE"}, Severity::state },
|
||||
{ {"info"}, Severity::info },
|
||||
{ {"INFO"}, Severity::info },
|
||||
{ {"detail"}, Severity::detail },
|
||||
{ {"debug"}, Severity::debug },
|
||||
{ {"DEBUG"}, Severity::debug },
|
||||
{ {"debug1"}, Severity::debug1 },
|
||||
{ {"DEBUG1"}, Severity::debug1 },
|
||||
{ {"debug2"}, Severity::debug2 },
|
||||
{ {"DEBUG2"}, Severity::debug2 },
|
||||
{ {"debug3"}, Severity::debug3 },
|
||||
{ {"DEBUG3"}, Severity::debug3 },
|
||||
{ {"debug4"}, Severity::debug4 },
|
||||
{ {"DEBUG4"}, Severity::debug4 },
|
||||
{ {"trace"}, Severity::trace },
|
||||
{ {"TRACE"}, Severity::trace }
|
||||
};
|
||||
|
||||
const array<string, 14> Logger::fSeverityNames =
|
||||
const array<string_view, 16> Logger::fSeverityNames =
|
||||
{
|
||||
{
|
||||
"NOLOG",
|
||||
@@ -101,17 +107,19 @@ const array<string, 14> Logger::fSeverityNames =
|
||||
"DEBUG2",
|
||||
"DEBUG1",
|
||||
"DEBUG",
|
||||
"DETAIL",
|
||||
"INFO",
|
||||
"STATE",
|
||||
"WARN",
|
||||
"IMPORTANT",
|
||||
"ALARM",
|
||||
"ERROR",
|
||||
"CRITICAL",
|
||||
"FATAL"
|
||||
}
|
||||
};
|
||||
|
||||
const array<string, 9> Logger::fVerbosityNames =
|
||||
const array<string_view, 9> Logger::fVerbosityNames =
|
||||
{
|
||||
{
|
||||
"verylow",
|
||||
@@ -139,12 +147,11 @@ map<Verbosity, VSpec> Logger::fVerbosities =
|
||||
{ Verbosity::user4, VSpec::Make(VSpec::Info::severity) }
|
||||
};
|
||||
|
||||
Logger::Logger(Severity severity, Verbosity verbosity, const string& file, const string& line, const string& func)
|
||||
Logger::Logger(Severity severity, Verbosity verbosity, std::string_view file, std::string_view line, std::string_view func)
|
||||
: fTimeCalculated(false)
|
||||
{
|
||||
if (!fIsDestructed) {
|
||||
size_t pos = file.rfind("/");
|
||||
|
||||
// fInfos.timestamp is filled conditionally
|
||||
// fInfos.us is filled conditionally
|
||||
fInfos.process_name = fProcessName;
|
||||
@@ -160,27 +167,27 @@ Logger::Logger(Severity severity, Verbosity verbosity, const string& file, const
|
||||
for (const auto info : spec.fInfos) {
|
||||
switch (info) {
|
||||
case VSpec::Info::process_name:
|
||||
fmt::format_to(fBWPrefix, "[{}]", fInfos.process_name);
|
||||
fmt::format_to(std::back_inserter(fBWPrefix), "[{}]", fInfos.process_name);
|
||||
break;
|
||||
case VSpec::Info::timestamp_us:
|
||||
FillTimeInfos();
|
||||
fmt::format_to(fBWPrefix, "[{:%H:%M:%S}.{:06}]", fmt::localtime(fInfos.timestamp), fInfos.us.count());
|
||||
fmt::format_to(std::back_inserter(fBWPrefix), "[{:%H:%M:%S}.{:06}]", fmt::localtime(fInfos.timestamp), fInfos.us.count());
|
||||
break;
|
||||
case VSpec::Info::timestamp_s:
|
||||
FillTimeInfos();
|
||||
fmt::format_to(fBWPrefix, "[{:%H:%M:%S}]", fmt::localtime(fInfos.timestamp));
|
||||
fmt::format_to(std::back_inserter(fBWPrefix), "[{:%H:%M:%S}]", fmt::localtime(fInfos.timestamp));
|
||||
break;
|
||||
case VSpec::Info::severity:
|
||||
fmt::format_to(fBWPrefix, "[{}]", fInfos.severity_name);
|
||||
fmt::format_to(std::back_inserter(fBWPrefix), "[{}]", fInfos.severity_name);
|
||||
break;
|
||||
case VSpec::Info::file_line_function:
|
||||
fmt::format_to(fBWPrefix, "[{}:{}:{}]", fInfos.file, fInfos.line, fInfos.func);
|
||||
fmt::format_to(std::back_inserter(fBWPrefix), "[{}:{}:{}]", fInfos.file, fInfos.line, fInfos.func);
|
||||
break;
|
||||
case VSpec::Info::file_line:
|
||||
fmt::format_to(fBWPrefix, "[{}:{}]", fInfos.file, fInfos.line);
|
||||
fmt::format_to(std::back_inserter(fBWPrefix), "[{}:{}]", fInfos.file, fInfos.line);
|
||||
break;
|
||||
case VSpec::Info::file:
|
||||
fmt::format_to(fBWPrefix, "[{}]", fInfos.file);
|
||||
fmt::format_to(std::back_inserter(fBWPrefix), "[{}]", fInfos.file);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -188,7 +195,7 @@ Logger::Logger(Severity severity, Verbosity verbosity, const string& file, const
|
||||
}
|
||||
|
||||
if (spec.fSize > 0) {
|
||||
fmt::format_to(fBWPrefix, " ");
|
||||
fmt::format_to(std::back_inserter(fBWPrefix), " ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,27 +203,27 @@ Logger::Logger(Severity severity, Verbosity verbosity, const string& file, const
|
||||
for (const auto info : spec.fInfos) {
|
||||
switch (info) {
|
||||
case VSpec::Info::process_name:
|
||||
fmt::format_to(fColorPrefix, "[{}]", ColorOut(Color::fgBlue, fInfos.process_name));
|
||||
fmt::format_to(std::back_inserter(fColorPrefix), "[{}]", ColorOut(Color::fgBlue, fInfos.process_name));
|
||||
break;
|
||||
case VSpec::Info::timestamp_us:
|
||||
FillTimeInfos();
|
||||
fmt::format_to(fColorPrefix, "[{}{:%H:%M:%S}.{:06}{}]", startColor(Color::fgCyan), fmt::localtime(fInfos.timestamp), fInfos.us.count(), endColor());
|
||||
fmt::format_to(std::back_inserter(fColorPrefix), "[{}{:%H:%M:%S}.{:06}{}]", startColor(Color::fgCyan), fmt::localtime(fInfos.timestamp), fInfos.us.count(), endColor());
|
||||
break;
|
||||
case VSpec::Info::timestamp_s:
|
||||
FillTimeInfos();
|
||||
fmt::format_to(fColorPrefix, "[{}{:%H:%M:%S}{}]", startColor(Color::fgCyan), fmt::localtime(fInfos.timestamp), endColor());
|
||||
fmt::format_to(std::back_inserter(fColorPrefix), "[{}{:%H:%M:%S}{}]", startColor(Color::fgCyan), fmt::localtime(fInfos.timestamp), endColor());
|
||||
break;
|
||||
case VSpec::Info::severity:
|
||||
fmt::format_to(fColorPrefix, "[{}]", GetColoredSeverityString(fInfos.severity));
|
||||
fmt::format_to(std::back_inserter(fColorPrefix), "[{}]", GetColoredSeverityString(fInfos.severity));
|
||||
break;
|
||||
case VSpec::Info::file_line_function:
|
||||
fmt::format_to(fColorPrefix, "[{}:{}:{}]", ColorOut(Color::fgBlue, fInfos.file), ColorOut(Color::fgYellow, fInfos.line), ColorOut(Color::fgBlue, fInfos.func));
|
||||
fmt::format_to(std::back_inserter(fColorPrefix), "[{}:{}:{}]", ColorOut(Color::fgBlue, fInfos.file), ColorOut(Color::fgYellow, fInfos.line), ColorOut(Color::fgBlue, fInfos.func));
|
||||
break;
|
||||
case VSpec::Info::file_line:
|
||||
fmt::format_to(fColorPrefix, "[{}:{}]", ColorOut(Color::fgBlue, fInfos.file), ColorOut(Color::fgYellow, fInfos.line));
|
||||
fmt::format_to(std::back_inserter(fColorPrefix), "[{}:{}]", ColorOut(Color::fgBlue, fInfos.file), ColorOut(Color::fgYellow, fInfos.line));
|
||||
break;
|
||||
case VSpec::Info::file:
|
||||
fmt::format_to(fColorPrefix, "[{}]", ColorOut(Color::fgBlue, fInfos.file));
|
||||
fmt::format_to(std::back_inserter(fColorPrefix), "[{}]", ColorOut(Color::fgBlue, fInfos.file));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -224,7 +231,7 @@ Logger::Logger(Severity severity, Verbosity verbosity, const string& file, const
|
||||
}
|
||||
|
||||
if (spec.fSize > 0) {
|
||||
fmt::format_to(fColorPrefix, " ");
|
||||
fmt::format_to(std::back_inserter(fColorPrefix), " ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,12 +291,14 @@ string Logger::GetColoredSeverityString(Severity severity)
|
||||
switch (severity) {
|
||||
case Severity::nolog: return "\033[01;39mNOLOG\033[0m"; break;
|
||||
case Severity::fatal: return "\033[01;31mFATAL\033[0m"; break;
|
||||
case Severity::critical: return "\033[01;31mCRITICAL\033[0m"; break;
|
||||
case Severity::error: return "\033[01;31mERROR\033[0m"; break;
|
||||
case Severity::alarm: return "\033[01;33mALARM\033[0m"; break;
|
||||
case Severity::important: return "\033[01;32mIMPORTANT\033[0m"; break;
|
||||
case Severity::warn: return "\033[01;33mWARN\033[0m"; break;
|
||||
case Severity::state: return "\033[01;35mSTATE\033[0m"; break;
|
||||
case Severity::info: return "\033[01;32mINFO\033[0m"; break;
|
||||
case Severity::detail: return "\033[01;32mDETAIL\033[0m"; break;
|
||||
case Severity::debug: return "\033[01;34mDEBUG\033[0m"; break;
|
||||
case Severity::debug1: return "\033[01;34mDEBUG1\033[0m"; break;
|
||||
case Severity::debug2: return "\033[01;34mDEBUG2\033[0m"; break;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014-2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* Copyright (C) 2014-2025 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <time.h> // time_t
|
||||
#include <type_traits> // is_same
|
||||
#include <unordered_map>
|
||||
#include <string_view>
|
||||
#include <utility> // pair
|
||||
|
||||
namespace fair
|
||||
@@ -59,29 +60,31 @@ enum class Severity : int
|
||||
debug2 = 4,
|
||||
debug1 = 5,
|
||||
debug = 6,
|
||||
info = 7,
|
||||
state = 8,
|
||||
warn = 9,
|
||||
important = 10,
|
||||
alarm = 11,
|
||||
error = 12,
|
||||
fatal = 13,
|
||||
detail = 7,
|
||||
info = 8,
|
||||
state = 9,
|
||||
warn = 10,
|
||||
important = 11,
|
||||
alarm = 12,
|
||||
error = 13,
|
||||
critical = 14,
|
||||
fatal = 15,
|
||||
// aliases
|
||||
warning = warn,
|
||||
// backwards-compatibility
|
||||
NOLOG = nolog,
|
||||
TRACE = trace,
|
||||
DEBUG4 = debug4,
|
||||
DEBUG3 = debug3,
|
||||
DEBUG2 = debug2,
|
||||
DEBUG1 = debug1,
|
||||
DEBUG = debug,
|
||||
INFO = info,
|
||||
STATE = state,
|
||||
WARNING = warn,
|
||||
WARN = warn,
|
||||
ERROR = error,
|
||||
FATAL = fatal
|
||||
NOLOG __attribute__((deprecated("Use LOG(nolog) instead (lowercase severity name)."))) = nolog,
|
||||
FATAL __attribute__((deprecated("Use LOG(fatal) instead (lowercase severity name)."))) = fatal,
|
||||
ERROR __attribute__((deprecated("Use LOG(error) instead (lowercase severity name)."))) = error,
|
||||
WARN __attribute__((deprecated("Use LOG(warn) instead (lowercase severity name)."))) = warn,
|
||||
WARNING __attribute__((deprecated("Use LOG(warning) instead (lowercase severity name)."))) = warn,
|
||||
STATE __attribute__((deprecated("Use LOG(state) instead (lowercase severity name)."))) = state,
|
||||
INFO __attribute__((deprecated("Use LOG(info) instead (lowercase severity name)."))) = info,
|
||||
DEBUG __attribute__((deprecated("Use LOG(debug) instead (lowercase severity name)."))) = debug,
|
||||
DEBUG1 __attribute__((deprecated("Use LOG(debug1) instead (lowercase severity name)."))) = debug1,
|
||||
DEBUG2 __attribute__((deprecated("Use LOG(debug2) instead (lowercase severity name)."))) = debug2,
|
||||
DEBUG3 __attribute__((deprecated("Use LOG(debug3) instead (lowercase severity name)."))) = debug3,
|
||||
DEBUG4 __attribute__((deprecated("Use LOG(debug4) instead (lowercase severity name)."))) = debug4,
|
||||
TRACE __attribute__((deprecated("Use LOG(trace) instead (lowercase severity name)."))) = trace
|
||||
};
|
||||
|
||||
// verbosity levels:
|
||||
@@ -174,19 +177,19 @@ struct LogMetaData
|
||||
{
|
||||
std::time_t timestamp;
|
||||
std::chrono::microseconds us;
|
||||
std::string process_name;
|
||||
std::string file;
|
||||
std::string line;
|
||||
std::string func;
|
||||
std::string severity_name;
|
||||
std::string_view process_name;
|
||||
std::string_view file;
|
||||
std::string_view line;
|
||||
std::string_view func;
|
||||
std::string_view severity_name;
|
||||
fair::Severity severity;
|
||||
};
|
||||
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
Logger(Severity severity, Verbosity verbosity, const std::string& file, const std::string& line, const std::string& func);
|
||||
Logger(Severity severity, const std::string& file, const std::string& line, const std::string& func)
|
||||
Logger(Severity severity, Verbosity verbosity, std::string_view file, std::string_view line, std::string_view func);
|
||||
Logger(Severity severity, std::string_view file, std::string_view line, std::string_view func)
|
||||
: Logger(severity, fVerbosity, file, line, func)
|
||||
{}
|
||||
virtual ~Logger() noexcept(false);
|
||||
@@ -243,7 +246,7 @@ class Logger
|
||||
|
||||
static std::string startColor(Color color) { return fmt::format("\033[01;{}m", static_cast<int>(color)); }
|
||||
static std::string endColor() { return "\033[0m"; }
|
||||
static std::string ColorOut(Color c, const std::string& s) { return fmt::format("\033[01;{}m{}\033[0m", static_cast<int>(c), s); }
|
||||
static std::string ColorOut(Color c, std::string_view s) { return fmt::format("\033[01;{}m{}\033[0m", static_cast<int>(c), s); }
|
||||
static std::string GetColoredSeverityString(Severity severity);
|
||||
|
||||
static void SetConsoleSeverity(const Severity severity);
|
||||
@@ -284,8 +287,8 @@ class Logger
|
||||
|
||||
static void RemoveFileSink();
|
||||
|
||||
static std::string SeverityName(Severity s) { return fSeverityNames.at(static_cast<size_t>(s)); }
|
||||
static std::string VerbosityName(Verbosity v) { return fVerbosityNames.at(static_cast<size_t>(v)); }
|
||||
static std::string_view SeverityName(Severity s) { return fSeverityNames.at(static_cast<size_t>(s)); }
|
||||
static std::string_view VerbosityName(Verbosity v) { return fVerbosityNames.at(static_cast<size_t>(v)); }
|
||||
|
||||
static void OnFatal(std::function<void()> func);
|
||||
|
||||
@@ -321,10 +324,10 @@ class Logger
|
||||
Logger& operator<<(std::ios_base& (*manip) (std::ios_base&));
|
||||
Logger& operator<<(std::ostream& (*manip) (std::ostream&));
|
||||
|
||||
static const std::unordered_map<std::string, Verbosity> fVerbosityMap;
|
||||
static const std::unordered_map<std::string, Severity> fSeverityMap;
|
||||
static const std::array<std::string, 14> fSeverityNames;
|
||||
static const std::array<std::string, 9> fVerbosityNames;
|
||||
static const std::unordered_map<std::string_view, Verbosity> fVerbosityMap;
|
||||
static const std::unordered_map<std::string_view, Severity> fSeverityMap;
|
||||
static const std::array<std::string_view, 16> fSeverityNames;
|
||||
static const std::array<std::string_view, 9> fVerbosityNames;
|
||||
|
||||
// protection for use after static destruction took place
|
||||
static bool fIsDestructed;
|
||||
|
@@ -32,5 +32,10 @@ endfunction()
|
||||
container(OS fedora VERSION 32)
|
||||
container(OS fedora VERSION 33)
|
||||
container(OS fedora VERSION 34)
|
||||
container(OS fedora VERSION 35)
|
||||
container(OS fedora VERSION 36)
|
||||
container(OS fedora VERSION 37)
|
||||
container(OS fedora VERSION 38)
|
||||
container(OS fedora VERSION 39)
|
||||
|
||||
add_custom_target(all-containers DEPENDS ${containers})
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014-2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* Copyright (C) 2015-2025 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
@@ -38,7 +38,7 @@ int main()
|
||||
Logger::SetConsoleSeverity(Severity::fatal);
|
||||
cout << "initial severity >" << Logger::GetConsoleSeverity() << "<" << endl << endl;
|
||||
|
||||
array<Severity, 14> severitiesUp{{ Severity::nolog, Severity::trace, Severity::debug4, Severity::debug3, Severity::debug2, Severity::debug1, Severity::debug, Severity::info, Severity::state, Severity::warn, Severity::important, Severity::alarm, Severity::error, Severity::fatal }};
|
||||
array<Severity, 16> severitiesUp{{ Severity::nolog, Severity::trace, Severity::debug4, Severity::debug3, Severity::debug2, Severity::debug1, Severity::debug, Severity::detail, Severity::info, Severity::state, Severity::warn, Severity::important, Severity::alarm, Severity::error, Severity::critical, Severity::fatal }};
|
||||
#ifdef FAIR_MIN_SEVERITY
|
||||
for (unsigned int i = static_cast<int>(Severity::FAIR_MIN_SEVERITY); i < severitiesUp.size(); ++i) {
|
||||
#else
|
||||
@@ -57,7 +57,7 @@ int main()
|
||||
Logger::SetConsoleSeverity(Severity::fatal);
|
||||
cout << "initial severity >" << Logger::GetConsoleSeverity() << "<" << endl << endl;
|
||||
|
||||
array<Severity, 14> severitiesDown{{ Severity::error, Severity::alarm, Severity::important, Severity::warn, Severity::state, Severity::info, Severity::debug, Severity::debug1, Severity::debug2, Severity::debug3, Severity::debug4, Severity::trace, Severity::nolog, Severity::fatal }};
|
||||
array<Severity, 16> severitiesDown{{ Severity::critical, Severity::error, Severity::alarm, Severity::important, Severity::warn, Severity::state, Severity::info, Severity::detail, Severity::debug, Severity::debug1, Severity::debug2, Severity::debug3, Severity::debug4, Severity::trace, Severity::nolog, Severity::fatal }};
|
||||
#ifdef FAIR_MIN_SEVERITY
|
||||
for (unsigned int i = 0; i < severitiesDown.size() - static_cast<int>(Severity::FAIR_MIN_SEVERITY) - 1; ++i) {
|
||||
#else
|
||||
|
@@ -24,12 +24,14 @@ void printEverySeverity()
|
||||
LOG(debug2) << "debug2 message, counter: " << i++;
|
||||
LOG(debug1) << "debug1 message, counter: " << i++;
|
||||
LOG(debug) << "debug message, counter: " << i++;
|
||||
LOG(detail) << "detail message, counter: " << i++;
|
||||
LOG(info) << "info message, counter: " << i++;
|
||||
LOG(state) << "state message, counter: " << i++;
|
||||
LOG(warn) << "warning message, counter: " << i++;
|
||||
LOG(important) << "important message, counter: " << i++;
|
||||
LOG(alarm) << "alarm message, counter: " << i++;
|
||||
LOG(error) << "error message, counter: " << i++;
|
||||
LOG(critical) << "critical message, counter: " << i++;
|
||||
LOG(fatal) << "fatal message, counter: " << i++;
|
||||
}
|
||||
|
||||
|
@@ -13,19 +13,21 @@ using namespace fair;
|
||||
|
||||
void printEverySeverity()
|
||||
{
|
||||
LOG(nolog) << "nolog message, counter: ";
|
||||
LOG(trace) << "trace message, counter: ";
|
||||
LOG(debug4) << "debug4 message, counter: ";
|
||||
LOG(debug3) << "debug3 message, counter: ";
|
||||
LOG(debug2) << "debug2 message, counter: ";
|
||||
LOG(debug1) << "debug1 message, counter: ";
|
||||
LOG(debug) << "debug message, counter: ";
|
||||
LOG(info) << "info message, counter: ";
|
||||
LOG(state) << "state message, counter: ";
|
||||
LOG(warn) << "warning message, counter: ";
|
||||
LOG(important) << "important message, counter: ";
|
||||
LOG(alarm) << "alarm message, counter: ";
|
||||
LOG(error) << "error message, counter: ";
|
||||
LOG(nolog) << "nolog message ";
|
||||
LOG(trace) << "trace message ";
|
||||
LOG(debug4) << "debug4 message ";
|
||||
LOG(debug3) << "debug3 message ";
|
||||
LOG(debug2) << "debug2 message ";
|
||||
LOG(debug1) << "debug1 message ";
|
||||
LOG(debug) << "debug message ";
|
||||
LOG(detail) << "detail message ";
|
||||
LOG(info) << "info message ";
|
||||
LOG(state) << "state message ";
|
||||
LOG(warn) << "warning message ";
|
||||
LOG(important) << "important message ";
|
||||
LOG(alarm) << "alarm message ";
|
||||
LOG(error) << "error message ";
|
||||
LOG(critical) << "critical message ";
|
||||
}
|
||||
|
||||
void silentlyPrintAllVerbositiesWithSeverity(Severity sev)
|
||||
|
@@ -27,12 +27,14 @@ uint32_t printEverySeverity(uint32_t i)
|
||||
LOG(debug2) << "debug2 message, counter: " << i++;
|
||||
LOG(debug1) << "debug1 message, counter: " << i++;
|
||||
LOG(debug) << "debug message, counter: " << i++;
|
||||
LOG(detail) << "detail message, counter: " << i++;
|
||||
LOG(info) << "info message, counter: " << i++;
|
||||
LOG(state) << "state message, counter: " << i++;
|
||||
LOG(warn) << "warning message, counter: " << i++;
|
||||
LOG(important) << "important message, counter: " << i++;
|
||||
LOG(alarm) << "alarm message, counter: " << i++;
|
||||
LOG(error) << "error message, counter: " << i++;
|
||||
LOG(critical) << "critical message, counter: " << i++;
|
||||
LOG(fatal) << "fatal message, counter: " << i++;
|
||||
|
||||
return i;
|
||||
|
Reference in New Issue
Block a user