Project
Loading...
Searching...
No Matches
FairLogger.h
Go to the documentation of this file.
1/********************************************************************************
2 * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3 * *
4 * This software is distributed under the terms of the *
5 * GNU Lesser General Public Licence (LGPL) version 3, *
6 * copied verbatim in the file "LICENSE" *
7 ********************************************************************************/
8/*
9 * FairLogger.h
10 *
11 * Created on: Mar 03, 2011
12 * Author: f.uhlig
13 */
14
15#ifndef BASE_FAIRLOGGER_H_
16#define BASE_FAIRLOGGER_H_
17
18#include <Rtypes.h> // for bool, FairLogger::Class, etc
19#include <fairlogger/Logger.h>
20#include <stdarg.h> // for va_list
21#include <string> // for operator<<
22#include <vector> // for vector
23
24#define MESSAGE_ORIGIN __FILE__, CONVERTTOSTRING(__LINE__), __FUNCTION__
25
26// backwards-compatibility with older FairLogger calls, TODO: delete me as soon as possible
39
40// backwards-compatibility with older FairLogger calls, TODO: delete me as soon as possible
41static const char* const LogLevelString[] =
42 {"FATAL", "ERROR", "WARNING", "INFO", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4"};
43
45{
46 public:
47 static FairLogger* GetLogger();
48
50 {
51 if (enabled) {
52 fair::Logger::SetConsoleSeverity(fConsoleSeverity);
53 } else {
54 fair::Logger::SetConsoleSeverity(fair::Severity::fatal);
55 }
56 }
57
58 void SetLogScreenLevel(const char* severity)
59 {
60 fConsoleSeverity = severity;
61 fair::Logger::SetConsoleSeverity(fConsoleSeverity);
62 }
63
65 {
66 if (enabled) {
67 fair::Logger::SetFileSeverity(fLogFileSeverity);
68 } else {
69 fair::Logger::SetFileSeverity(fair::Severity::fatal);
70 }
71 }
72
73 void SetLogFileLevel(const char* severity)
74 {
75 fLogFileSeverity = severity;
76 fair::Logger::SetFileSeverity(fLogFileSeverity);
77 }
78
79 void SetLogFileName(const std::string& name)
80 {
81 fLogFileName = name;
82 OpenLogFile();
83 }
84
85 void SetColoredLog(bool enabled) { fair::Logger::SetConsoleColor(enabled); }
86
87 void SetLogVerbosityLevel(const char* verbosity) { fair::Logger::SetVerbosity(verbosity); }
88
89 bool IsLogNeeded(fair::Severity severity);
91 deprecated("Use 'IsLogNeeded(fair::Severity severity)' or 'fair::Logger::Logging(const fair::Severity "
92 "severity)' or 'fair::Logger::Logging(const std::string& severityStr)'")));
93
94 void Fatal(const char* file, const char* line, const char* func, const char* format, ...)
95 __attribute__((deprecated("Use 'LOG(fatal) << content;' macro interface instead.")));
96 void Error(const char* file, const char* line, const char* func, const char* format, ...)
97 __attribute__((deprecated("Use 'LOG(error) << content;' macro interface instead.")));
98 void Warning(const char* file, const char* line, const char* func, const char* format, ...)
99 __attribute__((deprecated("Use 'LOG(warn) << content;' macro interface instead.")));
100 void Info(const char* file, const char* line, const char* func, const char* format, ...)
101 __attribute__((deprecated("Use 'LOG(info) << content;' macro interface instead.")));
102 void Debug(const char* file, const char* line, const char* func, const char* format, ...)
103 __attribute__((deprecated("Use 'LOG(debug) << content;' macro interface instead.")));
104 void Debug1(const char* file, const char* line, const char* func, const char* format, ...)
105 __attribute__((deprecated("Use 'LOG(debug1) << content;' macro interface instead.")));
106 void Debug2(const char* file, const char* line, const char* func, const char* format, ...)
107 __attribute__((deprecated("Use 'LOG(debug2) << content;' macro interface instead.")));
108 void Debug3(const char* file, const char* line, const char* func, const char* format, ...)
109 __attribute__((deprecated("Use 'LOG(debug3) << content;' macro interface instead.")));
110 void Debug4(const char* file, const char* line, const char* func, const char* format, ...)
111 __attribute__((deprecated("Use 'LOG(debug4) << content;' macro interface instead.")));
112
113 static char const endl __attribute__((
114 deprecated("Line break is now added automatically by the LOG macro, this variable only adds empty space.")));
115 static char const flush __attribute__((
116 deprecated("Data is now flushed automatically by the LOG macro, this variable only adds empty space.")));
117
118 void SetScreenStreamToCerr(bool /* useCerr */) {}
119
120 private:
121 static FairLogger* instance;
122
123 FairLogger();
124 FairLogger(const FairLogger&);
125 FairLogger operator=(const FairLogger&);
126
127 ~FairLogger() {}
128
129 void Log(fair::Severity level,
130 const char* file,
131 const char* line,
132 const char*,
133 const char* format,
134 va_list arglist);
135
136 const char* ConvertLogLevelToString(FairLogLevel level) const { return LogLevelString[level]; }
137
138 static void LogFatalMessage();
139
140 void OpenLogFile() { fair::Logger::InitFileSink(fLogFileSeverity, fLogFileName, false); }
141
142 void CloseLogFile() { fair::Logger::RemoveFileSink(); }
143
144 std::string fLogFileName;
145 std::string fLogFileSeverity;
146 std::string fConsoleSeverity;
147
148 int fBufferSize;
149 int fBufferSizeNeeded;
150 std::vector<char> fDynamicBuffer;
151 char* fBufferPointer;
152
153 ClassDef(FairLogger, 4);
154};
155
156#define gLogger (FairLogger::GetLogger())
157
158#endif // BASE_FAIRLOGGER_H_
#define verbosity
std::ostringstream debug
FairLogLevel
Definition FairLogger.h:28
@ DEBUG
Definition FairLogger.h:33
@ ERROR
Definition FairLogger.h:30
@ FATAL
Definition FairLogger.h:29
@ INFO
Definition FairLogger.h:32
@ WARNING
Definition FairLogger.h:31
@ DEBUG4
Definition FairLogger.h:37
@ DEBUG1
Definition FairLogger.h:34
@ DEBUG3
Definition FairLogger.h:36
@ DEBUG2
Definition FairLogger.h:35
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate increase X h configStandalone Camera window renderer OpenGL display display_camera Orient the camera such that the y axis is always upwards Full Screen MultiSample Anti Downsampling Anti Enable Vertical Sync Target frame or if the backend cannot limit to the refresh Use OpenGL indirect draws to reduce number of draw calls Display h configStandalone Vulkan display display_vulkan Have uniform buffers in host accessible device memory h configStandalone Internal display display_internal Number of updates the Qt GUI may send ahead of the last one the display has before it waits for the display Opacity of the console background Number of console lines the history is shortened to this when it reaches twice the size Time in seconds an info message fades out after setInfoTime h OpenGL display display Font size Do not use Freetype for font Renderer for event Frontend to use for event ROOT macros used as track filter Console script file
char error[CURL_ERROR_SIZE]
void Debug3(const char *file, const char *line, const char *func, const char *format,...) __attribute__((deprecated("Use 'LOG(debug3) << content
void SetLogVerbosityLevel(const char *verbosity)
Definition FairLogger.h:87
void SetLogScreenLevel(const char *severity)
Definition FairLogger.h:58
void SetLogFileName(const std::string &name)
Definition FairLogger.h:79
void Debug(const char *file, const char *line, const char *func, const char *format,...) __attribute__((deprecated("Use 'LOG(debug) << content
void Debug1(const char *file, const char *line, const char *func, const char *format,...) __attribute__((deprecated("Use 'LOG(debug1) << content
void Debug2(const char *file, const char *line, const char *func, const char *format,...) __attribute__((deprecated("Use 'LOG(debug2) << content
static FairLogger * GetLogger()
void SetLogFileLevel(const char *severity)
Definition FairLogger.h:73
void SetScreenStreamToCerr(bool)
Definition FairLogger.h:118
void Error(const char *file, const char *line, const char *func, const char *format,...) __attribute__((deprecated("Use 'LOG(error) << content
void SetLogToScreen(bool enabled)
Definition FairLogger.h:49
void SetColoredLog(bool enabled)
Definition FairLogger.h:85
bool IsLogNeeded(fair::Severity severity)
void SetLogToFile(bool enabled)
Definition FairLogger.h:64
void Info(const char *file, const char *line, const char *func, const char *format,...) __attribute__((deprecated("Use 'LOG(info) << content
bool IsLogNeeded(FairLogLevel level) __attribute__((deprecated("Use 'IsLogNeeded(fair macro interface instead
Definition FairLogger.h:90
void Debug4(const char *file, const char *line, const char *func, const char *format,...) __attribute__((deprecated("Use 'LOG(debug4) << content
void Warning(const char *file, const char *line, const char *func, const char *format,...) __attribute__((deprecated("Use 'LOG(warn) << content
GLuint const GLchar * name
Definition glcorearb.h:781
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition glcorearb.h:2513
GLint level
Definition glcorearb.h:275
GLenum GLenum severity
Definition glcorearb.h:2513
GLint GLint GLsizei GLint GLenum format
Definition glcorearb.h:275
void empty(int)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"