21 #ifndef TJUTILS_CONFIG_H
22 #define TJUTILS_CONFIG_H
23 #include <tjutils/config.h>
26 #include <tjutils/tjutils.h>
27 #include <tjutils/tjstream.h>
28 #include <tjutils/tjhandler.h>
29 #include <tjutils/tjlabel.h>
30 #include <tjutils/tjstatic.h>
31 #include <tjutils/tjstring.h>
32 #include <tjutils/tjcstd.h>
39 #define MAX_COMPONENT_SIZE 10
40 #define MAX_LOG_STRINGSIZE 25
48 enum logPriority { noLog=0, errorLog, warningLog, infoLog, significantDebug, normalDebug, verboseDebug, numof_log_priorities, ignoreArgument};
49 static const char* logPriorityLabel[]={
"noLog",
"errorLog",
"warningLog",
"infoLog",
"significantDebug",
"normalDebug",
"verboseDebug"};
50 AVOID_CC_WARNING(logPriorityLabel)
90 STD_string
str(
unsigned int maxwidth=0,
bool include_comp=
true)
const;
123 LogBase(
const char* component,
const char*
object,
const Labeled* labeledObject,
const char*
function)
124 : compLabel(component), objLabel(
object), namedObj(labeledObject), funcName(
function) {}
149 static bool register_component(
const char*,log_component_fptr);
150 static void unregister_component(
const char*);
169 static void init_static();
170 static void destroy_static();
175 friend class LogOneLine;
178 const char* compLabel;
179 const char* objLabel;
181 const char* funcName;
184 void flush_oneline(
const STD_string& txt,
logPriority level);
187 static void parse_log_cmdline_options(
int argc,
char *argv[],
const char* opt,
logPriority base);
192 struct Global :
public Labeled {
195 STD_map<STD_string,log_component_fptr> components;
196 STD_map<STD_string,logPriority> init_level;
204 friend class DebugDialog;
230 Log(
const char* objectLabel,
const char* functionName,
logPriority level=verboseDebug);
251 inline static logPriority get_log_level() {
return logLevel;}
258 void register_comp();
261 static bool registered;
274 ~LogOneLine() {log.flush_oneline(oss.str(),lev);}
276 STD_ostream& get_stream() {
return oss;}
281 STD_ostringstream oss;
287 #define RELEASE_LOG_LEVEL infoLog
292 #define ODINLOG(logobj,level) \
293 if ((level) > (logobj).get_log_level()) ; \
294 else LogOneLine(logobj,level).get_stream()
298 #define ODINLOG(logobj,level) \
299 if ((level) > RELEASE_LOG_LEVEL) ; \
300 else if ((level) > (logobj).get_log_level()) ; \
301 else LogOneLine(logobj,level).get_stream()
static void set_log_output_function(tracefunction func)
static bool set_log_levels(int argc, char *argv[], bool trigger_error=true)
static void set_levels(const char *str)
static void set_uniform_log_level(logPriority level)
static STD_string get_usage()
static const char * get_levels()
static void set_log_level(const char *compname, logPriority level)
Log(const char *objectLabel, const char *functionName, logPriority level=verboseDebug)
void(* tracefunction)(const LogMessage &msg)
void default_tracefunction(const LogMessage &msg)
STD_string str(unsigned int maxwidth=0, bool include_comp=true) const