Logging.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 ArmarX::core
19* @author Mirko Waechter ( mirko.waechter at kit dot edu)
20* @date 2012
21* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22* GNU General Public License
23*/
24
25#include "Logging.h"
26
30
31#include "SpamFilterData.h"
32
33using namespace armarx;
34
38 logSender(new LogSender())
39{
40
41
42 // for (LogSenderPtr myvar_bal = armarx::LogSender::createLogSender(); myvar_bal; myvar_bal.reset())
43 // if (loggingToll)
44 // {
45 // myvarVal << das;
46 // }
47}
48
52
53void
55{
56 this->tag = tag;
57}
58
59void
60Logging::setTag(const std::string& tagName)
61{
62 this->tag = LogTag(tagName);
63}
64
65void
67{
68 *logSender << minimumLoggingLevel << "setting logging level to "
70 logSender->flush();
71 minimumLoggingLevel = level;
72}
73
76 float deactivationDurationSec,
77 const std::string& identifier,
78 bool deactivate)
79{
80 if (deactivate)
81 {
82 std::unique_lock lock(*spamFilter->mutex);
83 spamFilter->durationSec = deactivationDurationSec;
84 spamFilter->identifier = identifier;
85
86 if (spamFilter->filterMap->count(identifier) == 0)
87 {
88 (*spamFilter->filterMap)[identifier].clear();
89 }
90
91 return spamFilter;
92 }
93
94
95 return SpamFilterDataPtr();
96}
97
99Logging::deactivateSpam(float deactivationDurationSec,
100 const std::string& identifier,
101 bool deactivate) const
102{
103 return ::deactivateSpam(spamFilter, deactivationDurationSec, identifier, deactivate);
104}
105
106const LogSenderPtr&
108{
109 return logSender;
110}
111
113Logging::loghelper(const char* file, int line, const char* function) const
114{
116 ->setLocalMinimumLoggingLevel(this->Logging::minimumLoggingLevel)
117 ->setFile(file)
118 ->setLine(line)
119 ->setFunction(function)
120 ->setTag(this->armarx::Logging::tag);
121}
122
123bool
125{
126 return (level < this->getEffectiveLoggingLevel());
127}
128
131{
133 {
135 }
136 else
137 {
138 return minimumLoggingLevel;
139 }
140}
141
143loghelper(const char* file, int line, const char* function)
144{
145 return armarx::LogSender::createLogSender()->setFile(file)->setLine(line)->setFunction(
146 function);
147}
148
149bool
154
156
158deactivateSpam(float deactivationDurationSec, const std::string& identifier, bool deactivate)
159{
160 return deactivateSpam(globalSpamFilter, deactivationDurationSec, identifier, deactivate);
161}
bool checkLogLevel(MessageTypeT level)
Definition Logging.cpp:150
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition Logging.cpp:75
SpamFilterDataPtr globalSpamFilter(new SpamFilterData())
LogSenderPtr loghelper(const char *file, int line, const char *function)
Definition Logging.cpp:143
Wrapper for the Log IceStorm topic with convenience methods for logging.
Definition LogSender.h:66
static LogSenderPtr createLogSender()
Definition LogSender.cpp:82
static std::string levelToString(MessageTypeT type)
static MessageTypeT GetGlobalMinimumLoggingLevel()
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
Definition Logging.cpp:99
LogSenderPtr loghelper(const char *file, int line, const char *function) const
Definition Logging.cpp:113
MessageTypeT minimumLoggingLevel
Definition Logging.h:279
bool checkLogLevel(MessageTypeT level) const
Definition Logging.cpp:124
SpamFilterDataPtr spamFilter
Definition Logging.h:280
void setTag(const LogTag &tag)
Definition Logging.cpp:54
void setLocalMinimumLoggingLevel(MessageTypeT level)
With setLocalMinimumLoggingLevel the minimum verbosity-level of log-messages can be set.
Definition Logging.cpp:66
virtual ~Logging()
Definition Logging.cpp:49
const LogSenderPtr & getLogSender() const
Retrieve log sender.
Definition Logging.cpp:107
MessageTypeT getEffectiveLoggingLevel() const
Definition Logging.cpp:130
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< SpamFilterData > SpamFilterDataPtr
Definition Logging.h:227
std::shared_ptr< LogSender > LogSenderPtr
Typedef of std::shared_ptr for convenience.
Definition Logging.h:224
MessageTypeT
Definition LogSender.h:46