Apache log4cxx  Version 0.11.0
filewatchdog.h
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 <time.h>
23 #include <log4cxx/helpers/pool.h>
24 #include <log4cxx/helpers/thread.h>
25 #include <log4cxx/file.h>
26 
27 namespace log4cxx
28 {
29 namespace helpers
30 {
31 
36 class LOG4CXX_EXPORT FileWatchdog
37 {
38  public:
39  virtual ~FileWatchdog();
43  static long DEFAULT_DELAY /*= 60000*/;
44 
45  protected:
50 
54  long delay;
55  log4cxx_time_t lastModif;
56  bool warnedAlready;
57  volatile unsigned int interrupted;
58 
59  protected:
60  FileWatchdog(const File& filename);
61  virtual void doOnChange() = 0;
62  void checkAndConfigure();
63 
64  public:
68  void setDelay(long delay1)
69  {
70  this->delay = delay1;
71  }
72 
73  void start();
74 
75  private:
76  static void* LOG4CXX_THREAD_FUNC run(apr_thread_t* thread, void* data);
77  Pool pool;
78  Thread thread;
79 
80  FileWatchdog(const FileWatchdog&);
81  FileWatchdog& operator=(const FileWatchdog&);
82 
83 };
84 } // namespace helpers
85 } // namespace log4cxx
86 
87 
88 #endif // _LOG4CXX_HELPERS_FILEWATCHDOG_H
This class implements an approximation of java.util.Thread.
Definition: thread.h:59
Check every now and then that a certain file has not changed.
Definition: filewatchdog.h:36
File file
The name of the file to observe for changes.
Definition: filewatchdog.h:49
Definition: pool.h:32
long delay
The delay to observe between every check.
Definition: filewatchdog.h:54
An abstract representation of file and directory path names.
Definition: file.h:45
Definition: appender.h:33
void setDelay(long delay1)
Set the delay to observe between each check of the file changes.
Definition: filewatchdog.h:68