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
10
12 LogType minimumPrintLevel,
13 LogType minimumForwardLevel,
14 LogCallback printCallback,
15 LogCallback forwardCallback) :
16 m_name(name),
17 m_tracePrintEnabled(minimumPrintLevel <= yarp::os::Log::TraceType),
18 m_debugPrintEnabled(minimumPrintLevel <= yarp::os::Log::DebugType),
19 m_infoPrintEnabled(minimumPrintLevel <= yarp::os::Log::InfoType),
20 m_warningPrintEnabled(minimumPrintLevel <= yarp::os::Log::WarningType),
21 m_errorPrintEnabled(minimumPrintLevel <= yarp::os::Log::ErrorType),
22 m_fatalPrintEnabled(minimumPrintLevel <= yarp::os::Log::FatalType),
23 m_traceForwardEnabled(minimumForwardLevel <= yarp::os::Log::TraceType),
24 m_debugForwardEnabled(minimumForwardLevel <= yarp::os::Log::DebugType),
25 m_infoForwardEnabled(minimumForwardLevel <= yarp::os::Log::InfoType),
26 m_warningForwardEnabled(minimumForwardLevel <= yarp::os::Log::WarningType),
27 m_errorForwardEnabled(minimumForwardLevel <= yarp::os::Log::ErrorType),
28 m_fatalForwardEnabled(minimumForwardLevel <= yarp::os::Log::FatalType),
29 m_printCallback(printCallback),
30 m_forwardCallback(forwardCallback)
31{
32 // FIXME Read enviroment variables, config files, etc to configure the component dynamically
33}
34
36{
37 switch (t) {
39 return (m_tracePrintEnabled.load() ? m_printCallback : nullptr);
41 return (m_debugPrintEnabled.load() ? m_printCallback : nullptr);
43 return (m_infoPrintEnabled.load() ? m_printCallback : nullptr);
45 return (m_warningPrintEnabled.load() ? m_printCallback : nullptr);
47 return (m_errorPrintEnabled.load() ? m_printCallback : nullptr);
49 return (m_fatalPrintEnabled.load() ? m_printCallback : nullptr);
50 default:
51 return nullptr;
52 }
53}
54
56{
57 switch (t) {
59 return (m_traceForwardEnabled.load() ? m_forwardCallback : nullptr);
61 return (m_debugForwardEnabled.load() ? m_forwardCallback : nullptr);
63 return (m_infoForwardEnabled.load() ? m_forwardCallback : nullptr);
65 return (m_warningForwardEnabled.load() ? m_forwardCallback : nullptr);
67 return (m_errorForwardEnabled.load() ? m_forwardCallback : nullptr);
69 return (m_fatalForwardEnabled.load() ? m_forwardCallback : nullptr);
70 default:
71 return nullptr;
72 }
73}
74
75#ifndef YARP_NO_DEPRECATED // Since YARP 3.4
76void LogComponent::setMinimumPrintLevel(LogType minimumPrintLevel)
77{
78 m_tracePrintEnabled = (minimumPrintLevel <= yarp::os::Log::TraceType);
79 m_debugPrintEnabled = (minimumPrintLevel <= yarp::os::Log::DebugType);
80 m_infoPrintEnabled = (minimumPrintLevel <= yarp::os::Log::InfoType);
82 m_errorPrintEnabled = (minimumPrintLevel <= yarp::os::Log::ErrorType);
83 m_fatalPrintEnabled = (minimumPrintLevel <= yarp::os::Log::FatalType);
84}
85
86void LogComponent::setMinimumForwardLevel(LogType minimumForwardLevel)
87{
88 m_traceForwardEnabled = (minimumForwardLevel <= yarp::os::Log::TraceType);
89 m_debugForwardEnabled = (minimumForwardLevel <= yarp::os::Log::DebugType);
90 m_infoForwardEnabled = (minimumForwardLevel <= yarp::os::Log::InfoType);
91 m_warningForwardEnabled = (minimumForwardLevel <= yarp::os::Log::WarningType);
92 m_errorForwardEnabled = (minimumForwardLevel <= yarp::os::Log::ErrorType);
93 m_fatalForwardEnabled = (minimumForwardLevel <= yarp::os::Log::FatalType);
94}
95#endif // YARP_NO_DEPRECATED
float t
A mini-server for performing network communication in the background.
LogComponent(const char *name, LogType minimumPrintLevel=yarp::os::Log::minimumPrintLevel(), LogType minimumForwardLevel=yarp::os::Log::minimumForwardLevel(), LogCallback printCallback=yarp::os::Log::printCallback(), LogCallback forwardCallback=yarp::os::Log::forwardCallback())
yarp::os::Log::LogCallback LogCallback
LogCallback printCallback(yarp::os::Log::LogType t) const
LogCallback forwardCallback(yarp::os::Log::LogType t) const
@ ErrorType
Definition Log.h:96
@ DebugType
Definition Log.h:93
@ TraceType
Definition Log.h:92
@ InfoType
Definition Log.h:94
@ FatalType
Definition Log.h:97
@ WarningType
Definition Log.h:95
void(*)(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) LogCallback
Definition Log.h:130
yarp::os::Log::LogCallback LogCallback
The main, catch-all namespace for YARP.
Definition dirs.h:16