| 1 | // |
| 2 | // LogFile.h |
| 3 | // |
| 4 | // Library: Foundation |
| 5 | // Package: Logging |
| 6 | // Module: LogFile |
| 7 | // |
| 8 | // Definition of the LogFile class. |
| 9 | // |
| 10 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
| 11 | // and Contributors. |
| 12 | // |
| 13 | // SPDX-License-Identifier: BSL-1.0 |
| 14 | // |
| 15 | |
| 16 | |
| 17 | #ifndef Foundation_LogFile_INCLUDED |
| 18 | #define Foundation_LogFile_INCLUDED |
| 19 | |
| 20 | |
| 21 | #include "Poco/Foundation.h" |
| 22 | |
| 23 | |
| 24 | #if defined(POCO_OS_FAMILY_WINDOWS) |
| 25 | #include "Poco/LogFile_WIN32.h" |
| 26 | #else |
| 27 | #include "Poco/LogFile_STD.h" |
| 28 | #endif |
| 29 | |
| 30 | |
| 31 | namespace Poco { |
| 32 | |
| 33 | |
| 34 | class Foundation_API LogFile: public LogFileImpl |
| 35 | /// This class is used by FileChannel to work |
| 36 | /// with a log file. |
| 37 | { |
| 38 | public: |
| 39 | LogFile(const std::string& path); |
| 40 | /// Creates the LogFile. |
| 41 | |
| 42 | ~LogFile(); |
| 43 | /// Destroys the LogFile. |
| 44 | |
| 45 | void write(const std::string& text, bool flush = true); |
| 46 | /// Writes the given text to the log file. |
| 47 | /// If flush is true, the text will be immediately |
| 48 | /// flushed to the file. |
| 49 | |
| 50 | UInt64 size() const; |
| 51 | /// Returns the current size in bytes of the log file. |
| 52 | |
| 53 | Timestamp creationDate() const; |
| 54 | /// Returns the date and time the log file was created. |
| 55 | |
| 56 | const std::string& path() const; |
| 57 | /// Returns the path given in the constructor. |
| 58 | }; |
| 59 | |
| 60 | |
| 61 | // |
| 62 | // inlines |
| 63 | // |
| 64 | inline void LogFile::write(const std::string& text, bool flush) |
| 65 | { |
| 66 | writeImpl(text, flush); |
| 67 | } |
| 68 | |
| 69 | |
| 70 | inline UInt64 LogFile::size() const |
| 71 | { |
| 72 | return sizeImpl(); |
| 73 | } |
| 74 | |
| 75 | |
| 76 | inline Timestamp LogFile::creationDate() const |
| 77 | { |
| 78 | return creationDateImpl(); |
| 79 | } |
| 80 | |
| 81 | |
| 82 | inline const std::string& LogFile::path() const |
| 83 | { |
| 84 | return pathImpl(); |
| 85 | } |
| 86 | |
| 87 | |
| 88 | } // namespace Poco |
| 89 | |
| 90 | |
| 91 | #endif // Foundation_LogFile_INCLUDED |
| 92 | |