YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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>
12namespace {
13std::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 const char* id)
26{
27 auto minlev = minimumServersqlPrintLevel.load();
28 if (type >= minlev) {
29 if (minlev <= yarp::os::Log::DebugType) {
30 yarp::os::Log::printCallback()(type, msg, file, line, func, systemtime, networktime, externaltime, comp_name, id);
31 } else {
32 static const char* err_str = "[ERROR] ";
33 static const char* warn_str = "[WARNING] ";
34 static const char* no_str = "";
35 printf("%s%s\n",
36 ((type == yarp::os::Log::ErrorType) ? err_str : ((type == yarp::os::Log::WarningType) ? warn_str : no_str)),
37 msg);
38 }
39 }
40}
41
43{
44 minimumServersqlPrintLevel = minumumLogType;
45}
static LogCallback printCallback()
Get current print callback.
Definition Log.cpp:873
@ ErrorType
Definition Log.h:96
@ DebugType
Definition Log.h:93
@ InfoType
Definition Log.h:94
@ WarningType
Definition Log.h:95
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, const char *id)