Coverage Report

Created: 2025-07-01 06:08

/src/logging-log4cxx/src/main/cpp/action.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
#include <log4cxx/logstring.h>
18
#include <log4cxx/rolling/action.h>
19
#include <log4cxx/private/action_priv.h>
20
#include <mutex>
21
#include <memory>
22
23
using namespace LOG4CXX_NS;
24
using namespace LOG4CXX_NS::rolling;
25
using namespace LOG4CXX_NS::helpers;
26
27
IMPLEMENT_LOG4CXX_OBJECT(Action)
28
29
Action::Action() :
30
0
  m_priv( std::make_unique<Action::ActionPrivate>() )
31
0
{
32
0
}
33
34
Action::Action( std::unique_ptr<ActionPrivate> priv ) :
35
0
  m_priv( std::move(priv) ) {}
36
37
Action::~Action()
38
0
{
39
0
}
40
41
/**
42
 * {@inheritDoc}
43
 */
44
void Action::run(LOG4CXX_NS::helpers::Pool& pool1)
45
0
{
46
0
  std::lock_guard<std::mutex> lock(m_priv->mutex);
47
48
0
  if (!m_priv->interrupted)
49
0
  {
50
0
    try
51
0
    {
52
0
      execute(pool1);
53
0
    }
54
0
    catch (std::exception& ex)
55
0
    {
56
0
      reportException(ex);
57
0
    }
58
59
0
    m_priv->complete = true;
60
0
    m_priv->interrupted = true;
61
0
  }
62
0
}
63
64
/**
65
 * {@inheritDoc}
66
 */
67
void Action::close()
68
0
{
69
0
  std::lock_guard<std::mutex> lock(m_priv->mutex);
70
0
  m_priv->interrupted = true;
71
0
}
72
73
/**
74
 * Tests if the action is complete.
75
 * @return true if action is complete.
76
 */
77
bool Action::isComplete() const
78
0
{
79
0
  return m_priv->complete;
80
0
}
81
82
/**
83
 * Capture exception.
84
 *
85
 * @param ex exception.
86
 */
87
void Action::reportException(const std::exception& /* ex */)
88
0
{
89
0
}