Apache Log4cxx
Version 2.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
filewatchdog.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_HELPERS_FILEWATCHDOG_H
19
#define _LOG4CXX_HELPERS_FILEWATCHDOG_H
20
21
#include <
log4cxx/logstring.h
>
22
#include <
log4cxx/file.h
>
23
#include <
log4cxx/spi/configurator.h
>
24
25
namespace
LOG4CXX_NS
26
{
27
namespace
helpers
28
{
29
class
FileWatchdog;
30
LOG4CXX_PTR_DEF
(
FileWatchdog
);
31
36
class
LOG4CXX_EXPORT
FileWatchdog
37
{
38
public
:
39
virtual
~FileWatchdog
();
43
static
long
DEFAULT_DELAY
/*= 60000 ms*/
;
44
45
protected
:
48
FileWatchdog
49
(
const
File
& filename
50
,
const
spi::ConfiguratorPtr& processor = {}
51
,
const
spi::LoggerRepositoryPtr
& target = {}
52
);
53
56
virtual
void
doOnChange
();
57
60
void
checkAndConfigure
();
61
64
const
File
&
file
();
65
66
public
:
69
FileWatchdogPtr
getSharedPtr
();
70
73
spi::ConfigurationStatus
getStatus
();
74
78
void
setDelay
(
long
millisecondDelay);
79
83
void
setFile
(
const
File
& filename);
84
88
void
start
();
89
93
void
stop
();
94
98
bool
is_active
();
99
103
static
void
stopAll
();
104
108
static
auto
startWatching
109
(
const
File
& filename
110
,
const
spi::ConfiguratorPtr& processor
111
,
const
spi::LoggerRepositoryPtr
& target
112
,
long
millisecondDelay
113
) ->
spi::ConfigurationStatus
;
114
private
:
115
116
FileWatchdog
(
const
FileWatchdog
&);
117
FileWatchdog
& operator=(
const
FileWatchdog
&);
118
119
struct
FileWatchdogPrivate;
120
LOG4CXX_DECLARE_PRIVATE_MEMBER(std::shared_ptr<FileWatchdogPrivate>, m_priv)
121
};
122
}
// namespace helpers
123
}
// namespace log4cxx
124
125
126
#endif
// _LOG4CXX_HELPERS_FILEWATCHDOG_H
log4cxx::File
An abstract representation of file and directory path names.
Definition
file.h:41
log4cxx::helpers::FileWatchdog
A monitor that will periodically check if a nominated file has changed and call the doOnChange virtua...
Definition
filewatchdog.h:37
log4cxx::helpers::FileWatchdog::checkAndConfigure
void checkAndConfigure()
Call doOnChange() if the watched file has changed.
log4cxx::helpers::FileWatchdog::getSharedPtr
FileWatchdogPtr getSharedPtr()
A shareable pointer to this.
log4cxx::helpers::FileWatchdog::DEFAULT_DELAY
static long DEFAULT_DELAY
The default delay between every file modification check, set to 60 seconds.
Definition
filewatchdog.h:43
log4cxx::helpers::FileWatchdog::FileWatchdog
FileWatchdog(const File &filename, const spi::ConfiguratorPtr &processor={}, const spi::LoggerRepositoryPtr &target={})
Monitors filename and optionally uses processor to configure target.
log4cxx::helpers::FileWatchdog::file
const File & file()
The watched file.
log4cxx::helpers::FileWatchdog::startWatching
static auto startWatching(const File &filename, const spi::ConfiguratorPtr &processor, const spi::LoggerRepositoryPtr &target, long millisecondDelay) -> spi::ConfigurationStatus
Call start() on a monitor of filename that uses processor to configure target.
log4cxx::helpers::FileWatchdog::is_active
bool is_active()
Is the task that periodically checks for a file change running?
log4cxx::helpers::FileWatchdog::doOnChange
virtual void doOnChange()
Call spi::Configurator::doConfigure if a processor has been provided.
log4cxx::helpers::FileWatchdog::start
void start()
Call checkAndConfigure() and then add an asynchronous task that periodically checks for a modificatio...
log4cxx::helpers::FileWatchdog::setDelay
void setDelay(long millisecondDelay)
Wait millisecondDelay between each check for file changes.
log4cxx::helpers::FileWatchdog::stop
void stop()
Stop the task that periodically checks for a file change.
log4cxx::helpers::FileWatchdog::stopAll
static void stopAll()
Stop all tasks that periodically check for a file change.
log4cxx::helpers::FileWatchdog::setFile
void setFile(const File &filename)
Change the watched file to filename.
log4cxx::helpers::FileWatchdog::~FileWatchdog
virtual ~FileWatchdog()
log4cxx::helpers::FileWatchdog::getStatus
spi::ConfigurationStatus getStatus()
The result from the most recent call to spi::Configurator::doConfigure.
configurator.h
file.h
logstring.h
log4cxx::helpers::LOG4CXX_PTR_DEF
LOG4CXX_PTR_DEF(Object)
log4cxx::spi::LoggerRepositoryPtr
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition
repositoryselector.h:28
log4cxx::spi::ConfigurationStatus
ConfigurationStatus
Definition
configurator.h:31
src
main
include
log4cxx
helpers
filewatchdog.h
Generated by
1.18.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
.