PlogArmarXAppender.cpp
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5*
6* ArmarX is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License version 2 as
8* published by the Free Software Foundation.
9*
10* ArmarX is distributed in the hope that it will be useful, but
11* WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17*
18* @package ArmarXCore::core
19* @date 2026
20* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21* GNU General Public License
22*/
23#include "PlogArmarXAppender.h"
24
25#if ARMARX_PLOG_SUPPORT
26
27#include <utility>
28
29#include <plog/Init.h>
30
32
33namespace armarx
34{
35 namespace
36 {
38 ToArmarXSeverity(plog::Severity severity)
39 {
40 switch (severity)
41 {
42 case plog::verbose:
44 case plog::debug:
46 case plog::info:
47 return MessageTypeT::INFO;
48 case plog::warning:
49 return MessageTypeT::WARN;
50 case plog::error:
52 case plog::fatal:
54 case plog::none:
55 default:
56 return MessageTypeT::INFO;
57 }
58 }
59 } // namespace
60
61 PlogArmarXAppender::PlogArmarXAppender(std::string tag) : tag(std::move(tag))
62 {
63 }
64
65 void
66 PlogArmarXAppender::write(const plog::Record& record)
67 {
68 (*LogSender::createLogSender()
69 ->setFile(record.getFile())
70 ->setLine(static_cast<int>(record.getLine()))
71 ->setFunction(record.getFunc())
72 ->setTag(LogTag(tag)))
73 << ToArmarXSeverity(record.getSeverity()) << record.getMessage();
74 }
75
76 void
77 RegisterPlogArmarXAppender()
78 {
79 static PlogArmarXAppender appender;
80 static bool initialized = false;
81 if (!initialized)
82 {
83 plog::init(plog::verbose, &appender);
84 initialized = true;
85 }
86 }
87
88} // namespace armarx
89
90#endif // ARMARX_PLOG_SUPPORT
This file offers overloads of toIce() and fromIce() functions for STL container types.
MessageTypeT
Definition LogSender.h:46