YARP
Yet Another Robot Platform
LogComponent.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
7 
8 #include <yarp/os/Os.h>
9 
10 #include <atomic>
11 #include <cstring>
12 namespace {
13 std::atomic<yarp::os::Log::LogType> minimumServersqlPrintLevel(yarp::os::Log::InfoType);
14 } // namespace
15 
17  const char* msg,
18  const char* file,
19  const unsigned int line,
20  const char* func,
21  double systemtime,
22  double networktime,
23  double externaltime,
24  const char* comp_name)
25 {
26  auto minlev = minimumServersqlPrintLevel.load();
27  if (type >= minlev) {
28  if (minlev <= yarp::os::Log::DebugType) {
29  yarp::os::Log::printCallback()(type, msg, file, line, func, systemtime, networktime, externaltime, comp_name);
30  } else {
31  static const char* err_str = "[ERROR] ";
32  static const char* warn_str = "[WARNING] ";
33  static const char* no_str = "";
34  printf("%s%s\n",
35  ((type == yarp::os::Log::ErrorType) ? err_str : ((type == yarp::os::Log::WarningType) ? warn_str : no_str)),
36  msg);
37  }
38  }
39 }
40 
42 {
43  minimumServersqlPrintLevel = minumumLogType;
44 }
static LogCallback printCallback()
Get current print callback.
Definition: Log.cpp:821
@ ErrorType
Definition: Log.h:78
@ DebugType
Definition: Log.h:75
@ InfoType
Definition: Log.h:76
@ WarningType
Definition: Log.h:77
void setMinumumLogType(yarp::os::Log::LogType minumumLogType)
void print_callback(yarp::os::Log::LogType type, const char *msg, const char *file, const unsigned int line, const char *func, double systemtime, double networktime, double externaltime, const char *comp_name)