1 | // |
---|
2 | // LogFile.h |
---|
3 | // |
---|
4 | // $Id: //poco/1.3/Foundation/include/Poco/LogFile.h#1 $ |
---|
5 | // |
---|
6 | // Library: Foundation |
---|
7 | // Package: Logging |
---|
8 | // Module: LogFile |
---|
9 | // |
---|
10 | // Definition of the LogFile class. |
---|
11 | // |
---|
12 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
---|
13 | // and Contributors. |
---|
14 | // |
---|
15 | // Permission is hereby granted, free of charge, to any person or organization |
---|
16 | // obtaining a copy of the software and accompanying documentation covered by |
---|
17 | // this license (the "Software") to use, reproduce, display, distribute, |
---|
18 | // execute, and transmit the Software, and to prepare derivative works of the |
---|
19 | // Software, and to permit third-parties to whom the Software is furnished to |
---|
20 | // do so, all subject to the following: |
---|
21 | // |
---|
22 | // The copyright notices in the Software and this entire statement, including |
---|
23 | // the above license grant, this restriction and the following disclaimer, |
---|
24 | // must be included in all copies of the Software, in whole or in part, and |
---|
25 | // all derivative works of the Software, unless such copies or derivative |
---|
26 | // works are solely in the form of machine-executable object code generated by |
---|
27 | // a source language processor. |
---|
28 | // |
---|
29 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
30 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
31 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT |
---|
32 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE |
---|
33 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, |
---|
34 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
35 | // DEALINGS IN THE SOFTWARE. |
---|
36 | // |
---|
37 | |
---|
38 | |
---|
39 | #ifndef Foundation_LogFile_INCLUDED |
---|
40 | #define Foundation_LogFile_INCLUDED |
---|
41 | |
---|
42 | |
---|
43 | #include "Poco/Foundation.h" |
---|
44 | |
---|
45 | |
---|
46 | #if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) |
---|
47 | #include "Poco/LogFile_WIN32U.h" |
---|
48 | #elif defined(POCO_OS_FAMILY_WINDOWS) |
---|
49 | #include "Poco/LogFile_WIN32.h" |
---|
50 | #elif defined(POCO_OS_FAMILY_VMS) |
---|
51 | #include "Poco/LogFile_VMS.h" |
---|
52 | #else |
---|
53 | #include "Poco/LogFile_STD.h" |
---|
54 | #endif |
---|
55 | |
---|
56 | |
---|
57 | namespace Poco { |
---|
58 | |
---|
59 | |
---|
60 | class Foundation_API LogFile: public LogFileImpl |
---|
61 | /// This class is used by FileChannel to work |
---|
62 | /// with a log file. |
---|
63 | { |
---|
64 | public: |
---|
65 | LogFile(const std::string& path); |
---|
66 | /// Creates the LogFile. |
---|
67 | |
---|
68 | ~LogFile(); |
---|
69 | /// Destroys the LogFile. |
---|
70 | |
---|
71 | void write(const std::string& text); |
---|
72 | /// Writes the given text to the log file. |
---|
73 | |
---|
74 | UInt64 size() const; |
---|
75 | /// Returns the current size in bytes of the log file. |
---|
76 | |
---|
77 | Timestamp creationDate() const; |
---|
78 | /// Returns the date and time the log file was created. |
---|
79 | |
---|
80 | const std::string& path() const; |
---|
81 | /// Returns the path given in the constructor. |
---|
82 | }; |
---|
83 | |
---|
84 | |
---|
85 | // |
---|
86 | // inlines |
---|
87 | // |
---|
88 | inline void LogFile::write(const std::string& text) |
---|
89 | { |
---|
90 | writeImpl(text); |
---|
91 | } |
---|
92 | |
---|
93 | |
---|
94 | inline UInt64 LogFile::size() const |
---|
95 | { |
---|
96 | return sizeImpl(); |
---|
97 | } |
---|
98 | |
---|
99 | |
---|
100 | inline Timestamp LogFile::creationDate() const |
---|
101 | { |
---|
102 | return creationDateImpl(); |
---|
103 | } |
---|
104 | |
---|
105 | |
---|
106 | inline const std::string& LogFile::path() const |
---|
107 | { |
---|
108 | return pathImpl(); |
---|
109 | } |
---|
110 | |
---|
111 | |
---|
112 | } // namespace Poco |
---|
113 | |
---|
114 | |
---|
115 | #endif // Foundation_LogFile_INCLUDED |
---|