source: pacpusframework/trunk/3rd/apache-log4cxx/include/log4cxx/helpers/filewatchdog.h@ 72

Last change on this file since 72 was 2, checked in by sgosseli, 12 years ago

Add 3rd party libraries (log4cxx).

File size: 3.0 KB
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
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
27namespace log4cxx
28{
29 namespace helpers
30 {
31
32 /**
33 Check every now and then that a certain file has not changed. If it
34 has, then call the #doOnChange method.
35 */
36 class LOG4CXX_EXPORT FileWatchdog
37 {
38 public:
39 virtual ~FileWatchdog();
40 /**
41 The default delay between every file modification check, set to 60
42 seconds. */
43 static long DEFAULT_DELAY /*= 60000*/;
44
45 protected:
46 /**
47 The name of the file to observe for changes.
48 */
49 File file;
50
51 /**
52 The delay to observe between every check.
53 By default set DEFAULT_DELAY.*/
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:
65 /**
66 Set the delay to observe between each check of the file changes.
67 */
68 void setDelay(long delay1)
69 { this->delay = delay1; }
70
71 void start();
72
73 private:
74 static void* LOG4CXX_THREAD_FUNC run(apr_thread_t* thread, void* data);
75 Pool pool;
76 Thread thread;
77
78 FileWatchdog(const FileWatchdog&);
79 FileWatchdog& operator=(const FileWatchdog&);
80
81 };
82 } // namespace helpers
83} // namespace log4cxx
84
85
86#endif // _LOG4CXX_HELPERS_FILEWATCHDOG_H
Note: See TracBrowser for help on using the repository browser.