pstore2
Public Member Functions | List of all members
pstore::basic_rotating_log< StreamTraits, FileSystemTraits > Class Template Referencefinal

#include <rotating_log.hpp>

Inheritance diagram for pstore::basic_rotating_log< StreamTraits, FileSystemTraits >:
Inheritance graph
[legend]
Collaboration diagram for pstore::basic_rotating_log< StreamTraits, FileSystemTraits >:
Collaboration graph
[legend]

Public Member Functions

 basic_rotating_log (std::string base_name, std::streamoff max_bytes, unsigned num_backups, StreamTraits const &traits=StreamTraits(), FileSystemTraits const &fs_traits=FileSystemTraits())
 
 basic_rotating_log (basic_rotating_log const &)=delete
 
 basic_rotating_log (basic_rotating_log &&)=delete
 
basic_rotating_logoperator= (basic_rotating_log const &)=delete
 
basic_rotating_logoperator= (basic_rotating_log &&) noexcept=delete
 
void log_impl (std::string const &message) override
 Writes the supplied string to the log. More...
 
bool is_open () const
 (for testing)
 
StreamTraits & stream_traits ()
 
FileSystemTraits & file_system_traits ()
 
StreamTraits::stream_type & stream ()
 
- Public Member Functions inherited from pstore::basic_logger
void log (priority p, std::string const &message) final
 
- Public Member Functions inherited from pstore::logger
 logger (logger const &)=delete
 
 logger (logger &&) noexcept=delete
 
loggeroperator= (logger const &)=delete
 
loggeroperator= (logger &&) noexcept=delete
 
void set_priority (priority const p) noexcept
 
priority get_priority () const noexcept
 
virtual void log (priority p, gsl::czstring message, int d)
 
virtual void log (priority p, gsl::czstring message, unsigned d)
 
virtual void log (priority p, gsl::czstring message, long d)
 
virtual void log (priority p, gsl::czstring message, unsigned long d)
 
virtual void log (priority p, gsl::czstring message, long long d)
 
virtual void log (priority p, gsl::czstring message, unsigned long long d)
 
virtual void log (priority p, gsl::czstring message)
 
virtual void log (priority p, gsl::czstring part1, gsl::czstring part2)
 
virtual void log (priority p, gsl::czstring part1, quoted part2)
 
void log (priority const p, gsl::czstring const message, std::string const &d)
 

Additional Inherited Members

- Public Types inherited from pstore::logger
enum  priority {
  priority::emergency, priority::alert, priority::critical, priority::error,
  priority::warning, priority::notice, priority::info, priority::debug
}
 
- Static Public Member Functions inherited from pstore::basic_logger
static gsl::czstring priority_string (priority p) noexcept
 
static std::string get_current_thread_name ()
 
static std::size_t time_string (std::time_t t, gsl::span< char, time_buffer_size > const &buffer)
 
- Static Public Attributes inherited from pstore::basic_logger
static constexpr std::size_t const time_buffer_size = sizeof "YYYY-MM-DDTHH:mm:SS+ZZZZ"
 

Detailed Description

template<typename StreamTraits, typename FileSystemTraits>
class pstore::basic_rotating_log< StreamTraits, FileSystemTraits >

Template Parameters
StreamTraitsA structure which must:
  • Define a type 'stream_type' which is the type of output stream, such as std::ostream or std::ostringstream.
  • Define the following member functions: void open (stream_type & s, std::string const & name, std::ios_base::openmode mode); void close (stream_type & s); void clear (stream_type &);
FileSystemTraitsA structure which must:
  • Define the following member functions: bool exists (std::string const & path); void rename (std::string const & from, std::string const & to); void unlink (std::string const & path);

Constructor & Destructor Documentation

◆ basic_rotating_log()

template<typename StreamTraits , typename FileSystemTraits >
pstore::basic_rotating_log< StreamTraits, FileSystemTraits >::basic_rotating_log ( std::string  base_name,
std::streamoff  max_bytes,
unsigned  num_backups,
StreamTraits const &  traits = StreamTraits (),
FileSystemTraits const &  fs_traits = FileSystemTraits () 
)
Parameters
base_nameThe base file name to which an integer is appended for backup files.
max_bytesThe maximum number of bytes to which an active log file is allowed to grow before we perform a rotation and begin writing that a new file. Set to 0 to allow the size to be unlimited (implying that rotation will never occur).
num_backupsThe number of backup files to created and rotated. Set to 0 to cause no backups to be made.
traitsThe stream traits to be associated with the log.
fs_traitsThe file-system traits to be associated with the log.
Note
Both num_backups and max_size must be greater than zero before rollover is enabled.

Member Function Documentation

◆ log_impl()

template<typename StreamTraits , typename FileSystemTraits >
void pstore::basic_rotating_log< StreamTraits, FileSystemTraits >::log_impl ( std::string const &  message)
overridevirtual

Writes the supplied string to the log.

If the current log file would become too large (as defined by the max_bytes constructor parameter), then a rotation is performed.

Implements pstore::basic_logger.


The documentation for this class was generated from the following file: