Coverage Report

Created: 2026-06-15 06:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/logging-log4cxx/src/main/cpp/onlyonceerrorhandler.cpp
Line
Count
Source
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
461
  m_priv(std::make_unique<OnlyOnceErrorHandlerPrivate>())
35
461
{
36
461
}
Unexecuted instantiation: log4cxx::helpers::OnlyOnceErrorHandler::OnlyOnceErrorHandler()
log4cxx::helpers::OnlyOnceErrorHandler::OnlyOnceErrorHandler()
Line
Count
Source
34
461
  m_priv(std::make_unique<OnlyOnceErrorHandlerPrivate>())
35
461
{
36
461
}
37
38
461
OnlyOnceErrorHandler::~OnlyOnceErrorHandler(){}
39
40
void OnlyOnceErrorHandler::setLogger(const LoggerPtr&)
41
0
{
42
0
}
43
44
#if LOG4CXX_ABI_VERSION <= 15
45
void OnlyOnceErrorHandler::activateOptions(Pool&)
46
0
{
47
0
}
48
#endif
49
50
void OnlyOnceErrorHandler::setOption(const LogString&, const LogString&)
51
0
{
52
0
}
53
54
void OnlyOnceErrorHandler::error(const LogString& message, const std::exception& e,
55
  int) const
56
1
{
57
1
  if (m_priv->firstTime)
58
1
  {
59
1
    LogLog::error(message, e);
60
1
    m_priv->firstTime = false;
61
1
  }
62
1
}
63
64
void OnlyOnceErrorHandler::error(const LogString& message, const std::exception& e,
65
  int errorCode, const LOG4CXX_NS::spi::LoggingEventPtr&) const
66
0
{
67
0
  error(message, e, errorCode);
68
0
}
69
70
71
void OnlyOnceErrorHandler::error(const LogString& message) const
72
0
{
73
0
  if (m_priv->firstTime)
74
0
  {
75
0
    LogLog::error(message);
76
0
    m_priv->firstTime = false;
77
0
  }
78
0
}
79
80
81
void OnlyOnceErrorHandler::setAppender(const AppenderPtr&)
82
0
{
83
0
}
84
85
86
void OnlyOnceErrorHandler::setBackupAppender(const AppenderPtr&)
87
0
{
88
0
}
89
90
bool OnlyOnceErrorHandler::errorReported() const
91
0
{
92
0
  return !m_priv->firstTime;
93
0
}
94