Apache Log4cxx
Version 1.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
levelchange.h
Go to the documentation of this file.
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
#ifndef LOG4CXX_LEVEL_CHANGE_HDR_
19
#define LOG4CXX_LEVEL_CHANGE_HDR_
20
21
#include <
log4cxx/logmanager.h
>
22
#include <
log4cxx/logger.h
>
23
24
namespace
LOG4CXX_NS
25
{
26
41
class
LevelChange
42
{
43
LoggerPtr
m_otherCategory;
44
LevelPtr
m_savedLevel;
45
public
:
// ...structors
47
LevelChange
(
const
LoggerPtr
& otherCategory,
const
LevelPtr
& level)
48
: m_otherCategory(otherCategory)
49
, m_savedLevel(otherCategory->getLevel())
50
{
51
m_otherCategory->setLevel(level);
52
}
53
54
LevelChange
(
const
LoggerPtr
& otherCategory,
const
LoggerPtr
& thisCategory)
55
:
LevelChange
(otherCategory, thisCategory->getLevel())
56
{
57
}
58
59
template
<
class
StringType>
60
LevelChange
(
const
StringType& otherCategory,
const
LevelPtr
& level)
61
:
LevelChange
(
LogManager
::getLogger(otherCategory), level)
62
{
63
}
64
65
template
<
class
StringType>
66
LevelChange
(
const
StringType& otherCategory,
const
LoggerPtr
& thisCategory)
67
:
LevelChange
(
LogManager
::getLogger(otherCategory), thisCategory->getLevel())
68
{
69
}
70
71
~LevelChange
()
72
{
73
m_otherCategory->setLevel(m_savedLevel);
74
}
75
private
:
// Prevent copies and assignment
76
LevelChange
(
const
LevelChange
&) =
delete
;
77
LevelChange
(
LevelChange
&&) =
delete
;
78
LevelChange
& operator=(
const
LevelChange
&) =
delete
;
79
LevelChange
& operator=(
LevelChange
&&) =
delete
;
80
};
81
82
}
// namespace LOG4CXX_NS
83
84
#endif
// LOG4CXX_LEVEL_CHANGE_HDR_
log4cxx::LevelChange
Changes a verbosity level for the instance variable's lifetime.
Definition
levelchange.h:42
log4cxx::LevelChange::LevelChange
LevelChange(const StringType &otherCategory, const LoggerPtr &thisCategory)
Set the logger named otherCategory to the level of thisCategory.
Definition
levelchange.h:66
log4cxx::LevelChange::~LevelChange
~LevelChange()
Restore the verbosity level of the other logger.
Definition
levelchange.h:71
log4cxx::LevelChange::LevelChange
LevelChange(const LoggerPtr &otherCategory, const LoggerPtr &thisCategory)
Set otherCategory to the level of thisCategory.
Definition
levelchange.h:54
log4cxx::LevelChange::LevelChange
LevelChange(const LoggerPtr &otherCategory, const LevelPtr &level)
Set otherCategory to level.
Definition
levelchange.h:47
log4cxx::LevelChange::LevelChange
LevelChange(const StringType &otherCategory, const LevelPtr &level)
Set the logger named otherCategory to level.
Definition
levelchange.h:60
log4cxx::LogManager
Use the LogManager class to retreive Logger instances or to operate on the current LoggerRepository.
Definition
logmanager.h:45
logger.h
logmanager.h
log4cxx::LevelPtr
std::shared_ptr< Level > LevelPtr
Definition
optionconverter.h:28
log4cxx::LoggerPtr
std::shared_ptr< Logger > LoggerPtr
Definition
defaultloggerfactory.h:27
src
main
include
log4cxx
levelchange.h
Generated by
1.17.0 on
SITE_PUBLISHED_DATE
Copyright © 2017-2026
Apache Software Foundation
. Apache, Chainsaw, log4cxx, Log4j, Log4net, log4php and the Apache logo are
trademarks or registered trademarks
of The Apache Software Foundation.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Privacy Policy
.