Apache Log4cxx  Version 2.0.0
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>
24
25namespace LOG4CXX_NS
26{
27namespace helpers
28{
29class FileWatchdog;
31
36class LOG4CXX_EXPORT FileWatchdog
37{
38 public:
39 virtual ~FileWatchdog();
43 static long DEFAULT_DELAY /*= 60000 ms*/;
44
45 protected:
49 ( const File& filename
50 , const spi::ConfiguratorPtr& processor = {}
51 , const spi::LoggerRepositoryPtr& target = {}
52 );
53
56 virtual void doOnChange();
57
61
64 const File& file();
65
66 public:
69 FileWatchdogPtr getSharedPtr();
70
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
114 private:
115
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
An abstract representation of file and directory path names.
Definition file.h:41
A monitor that will periodically check if a nominated file has changed and call the doOnChange virtua...
Definition filewatchdog.h:37
void checkAndConfigure()
Call doOnChange() if the watched file has changed.
FileWatchdogPtr getSharedPtr()
A shareable pointer to this.
static long DEFAULT_DELAY
The default delay between every file modification check, set to 60 seconds.
Definition filewatchdog.h:43
FileWatchdog(const File &filename, const spi::ConfiguratorPtr &processor={}, const spi::LoggerRepositoryPtr &target={})
Monitors filename and optionally uses processor to configure target.
const File & file()
The watched file.
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.
bool is_active()
Is the task that periodically checks for a file change running?
virtual void doOnChange()
Call spi::Configurator::doConfigure if a processor has been provided.
void start()
Call checkAndConfigure() and then add an asynchronous task that periodically checks for a modificatio...
void setDelay(long millisecondDelay)
Wait millisecondDelay between each check for file changes.
void stop()
Stop the task that periodically checks for a file change.
static void stopAll()
Stop all tasks that periodically check for a file change.
void setFile(const File &filename)
Change the watched file to filename.
spi::ConfigurationStatus getStatus()
The result from the most recent call to spi::Configurator::doConfigure.
LOG4CXX_PTR_DEF(Object)
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition repositoryselector.h:28
ConfigurationStatus
Definition configurator.h:31