YARP
Yet Another Robot Platform
LogComponent.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
10 
11 #include <yarp/os/Os.h>
12 
13 #include <atomic>
14 #include <cstring>
15 namespace {
16 std::atomic<yarp::os::Log::LogType> minimumServersqlPrintLevel(yarp::os::Log::InfoType);
17 } // namespace
18 
20  const char* msg,
21  const char* file,
22  const unsigned int line,
23  const char* func,
24  double systemtime,
25  double networktime,
26  double externaltime,
27  const char* comp_name)
28 {
29  auto minlev = minimumServersqlPrintLevel.load();
30  if (type >= minlev) {
31  if (minlev <= yarp::os::Log::DebugType) {
32  yarp::os::Log::printCallback()(type, msg, file, line, func, systemtime, networktime, externaltime, comp_name);
33  } else {
34  static const char* err_str = "[ERROR] ";
35  static const char* warn_str = "[WARNING] ";
36  static const char* no_str = "";
37  printf("%s%s\n",
38  ((type == yarp::os::Log::ErrorType) ? err_str : ((type == yarp::os::Log::WarningType) ? warn_str : no_str)),
39  msg);
40  }
41  }
42 }
43 
45 {
46  minimumServersqlPrintLevel = minumumLogType;
47 }
yarp::os::Log::InfoType
@ InfoType
Definition: Log.h:79
yarp::os::Log::ErrorType
@ ErrorType
Definition: Log.h:81
yarp::os::Log::WarningType
@ WarningType
Definition: Log.h:80
yarp::serversql::impl::LogComponent::setMinumumLogType
void setMinumumLogType(yarp::os::Log::LogType minumumLogType)
Definition: LogComponent.cpp:44
yarp::os::Log::LogType
LogType
Definition: Log.h:75
LogComponent.h
Os.h
yarp::os::Log::printCallback
static LogCallback printCallback()
Get current print callback.
Definition: Log.cpp:852
yarp::os::Log::DebugType
@ DebugType
Definition: Log.h:78
yarp::serversql::impl::LogComponent::print_callback
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)
Definition: LogComponent.cpp:19