Coverage Report

Created: 2025-07-18 06:17

/src/logging-log4cxx/src/main/cpp/onlyonceerrorhandler.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
#include <log4cxx/appender.h>
19
#include <log4cxx/logger.h>
20
#include <log4cxx/helpers/onlyonceerrorhandler.h>
21
#include <log4cxx/helpers/loglog.h>
22
23
using namespace LOG4CXX_NS;
24
using namespace LOG4CXX_NS::helpers;
25
using namespace LOG4CXX_NS::spi;
26
27
IMPLEMENT_LOG4CXX_OBJECT(OnlyOnceErrorHandler)
28
29
struct OnlyOnceErrorHandler::OnlyOnceErrorHandlerPrivate{
30
  mutable bool firstTime = true;
31
};
32
33
OnlyOnceErrorHandler::OnlyOnceErrorHandler() :
34
0
  m_priv(std::make_unique<OnlyOnceErrorHandlerPrivate>())
35
0
{
36
0
}
Unexecuted instantiation: log4cxx::helpers::OnlyOnceErrorHandler::OnlyOnceErrorHandler()
Unexecuted instantiation: log4cxx::helpers::OnlyOnceErrorHandler::OnlyOnceErrorHandler()
37
38
0
OnlyOnceErrorHandler::~OnlyOnceErrorHandler(){}
39
40
void OnlyOnceErrorHandler::setLogger(const LoggerPtr&)
41
0
{
42
0
}
43
44
void OnlyOnceErrorHandler::activateOptions(Pool&)
45
0
{
46
0
}
47
48
void OnlyOnceErrorHandler::setOption(const LogString&, const LogString&)
49
0
{
50
0
}
51
52
void OnlyOnceErrorHandler::error(const LogString& message, const std::exception& e,
53
  int) const
54
0
{
55
0
  if (m_priv->firstTime)
56
0
  {
57
0
    LogLog::error(message, e);
58
0
    m_priv->firstTime = false;
59
0
  }
60
0
}
61
62
void OnlyOnceErrorHandler::error(const LogString& message, const std::exception& e,
63
  int errorCode, const LOG4CXX_NS::spi::LoggingEventPtr&) const
64
0
{
65
0
  error(message, e, errorCode);
66
0
}
67
68
69
void OnlyOnceErrorHandler::error(const LogString& message) const
70
0
{
71
0
  if (m_priv->firstTime)
72
0
  {
73
0
    LogLog::error(message);
74
0
    m_priv->firstTime = false;
75
0
  }
76
0
}
77
78
79
void OnlyOnceErrorHandler::setAppender(const AppenderPtr&)
80
0
{
81
0
}
82
83
84
void OnlyOnceErrorHandler::setBackupAppender(const AppenderPtr&)
85
0
{
86
0
}
87
88
bool OnlyOnceErrorHandler::errorReported() const
89
0
{
90
0
  return !m_priv->firstTime;
91
0
}
92