LogFile.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // LogFile.h
  3. //
  4. // $Id: //poco/1.4/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. // SPDX-License-Identifier: BSL-1.0
  16. //
  17. #ifndef Foundation_LogFile_INCLUDED
  18. #define Foundation_LogFile_INCLUDED
  19. #include "Poco/Foundation.h"
  20. #if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
  21. #include "Poco/LogFile_WIN32U.h"
  22. #elif defined(POCO_OS_FAMILY_WINDOWS)
  23. #include "Poco/LogFile_WIN32.h"
  24. #elif defined(POCO_OS_FAMILY_VMS)
  25. #include "Poco/LogFile_VMS.h"
  26. #else
  27. #include "Poco/LogFile_STD.h"
  28. #endif
  29. namespace Poco {
  30. class Foundation_API LogFile: public LogFileImpl
  31. /// This class is used by FileChannel to work
  32. /// with a log file.
  33. {
  34. public:
  35. LogFile(const std::string& path);
  36. /// Creates the LogFile.
  37. ~LogFile();
  38. /// Destroys the LogFile.
  39. void write(const std::string& text, bool flush = true);
  40. /// Writes the given text to the log file.
  41. /// If flush is true, the text will be immediately
  42. /// flushed to the file.
  43. UInt64 size() const;
  44. /// Returns the current size in bytes of the log file.
  45. Timestamp creationDate() const;
  46. /// Returns the date and time the log file was created.
  47. const std::string& path() const;
  48. /// Returns the path given in the constructor.
  49. };
  50. //
  51. // inlines
  52. //
  53. inline void LogFile::write(const std::string& text, bool flush)
  54. {
  55. writeImpl(text, flush);
  56. }
  57. inline UInt64 LogFile::size() const
  58. {
  59. return sizeImpl();
  60. }
  61. inline Timestamp LogFile::creationDate() const
  62. {
  63. return creationDateImpl();
  64. }
  65. inline const std::string& LogFile::path() const
  66. {
  67. return pathImpl();
  68. }
  69. } // namespace Poco
  70. #endif // Foundation_LogFile_INCLUDED