2012-04-29 20:52:25 +02:00
|
|
|
//
|
|
|
|
// LogFile.h
|
|
|
|
//
|
|
|
|
// Library: Foundation
|
|
|
|
// Package: Logging
|
|
|
|
// Module: LogFile
|
|
|
|
//
|
|
|
|
// Definition of the LogFile class.
|
|
|
|
//
|
|
|
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
|
|
|
// and Contributors.
|
|
|
|
//
|
2014-05-04 21:02:42 +02:00
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
2012-04-29 20:52:25 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef Foundation_LogFile_INCLUDED
|
|
|
|
#define Foundation_LogFile_INCLUDED
|
|
|
|
|
|
|
|
#include "Poco/Foundation.h"
|
2024-03-09 12:00:15 +01:00
|
|
|
#include "Poco/Timestamp.h"
|
|
|
|
#include "Poco/FileStream.h"
|
2012-04-29 20:52:25 +02:00
|
|
|
|
|
|
|
namespace Poco {
|
|
|
|
|
|
|
|
|
2024-03-09 12:00:15 +01:00
|
|
|
class Foundation_API LogFile
|
2012-04-29 20:52:25 +02:00
|
|
|
/// This class is used by FileChannel to work
|
|
|
|
/// with a log file.
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LogFile(const std::string& path);
|
|
|
|
/// Creates the LogFile.
|
|
|
|
|
|
|
|
~LogFile();
|
|
|
|
/// Destroys the LogFile.
|
|
|
|
|
2012-08-22 05:25:25 +02:00
|
|
|
void write(const std::string& text, bool flush = true);
|
2012-04-29 20:52:25 +02:00
|
|
|
/// Writes the given text to the log file.
|
2012-08-22 05:25:25 +02:00
|
|
|
/// If flush is true, the text will be immediately
|
|
|
|
/// flushed to the file.
|
|
|
|
|
2012-04-29 20:52:25 +02:00
|
|
|
UInt64 size() const;
|
|
|
|
/// Returns the current size in bytes of the log file.
|
2017-11-09 11:15:18 +01:00
|
|
|
|
2012-04-29 20:52:25 +02:00
|
|
|
Timestamp creationDate() const;
|
|
|
|
/// Returns the date and time the log file was created.
|
2017-11-09 11:15:18 +01:00
|
|
|
|
2012-04-29 20:52:25 +02:00
|
|
|
const std::string& path() const;
|
|
|
|
/// Returns the path given in the constructor.
|
|
|
|
|
2024-03-09 12:00:15 +01:00
|
|
|
private:
|
|
|
|
std::string _path;
|
|
|
|
mutable Poco::FileOutputStream _str;
|
|
|
|
Timestamp _creationDate;
|
|
|
|
UInt64 _size;
|
|
|
|
};
|
2012-04-29 20:52:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace Poco
|
|
|
|
|
|
|
|
|
|
|
|
#endif // Foundation_LogFile_INCLUDED
|