Loading...
Searching...
No Matches
FileLogger.h
Go to the documentation of this file.
// -*- c++ -*-
//------------------------------------------------------------------------------
// $Id: FileLogger.h,v 1.4 2005/10/08 02:42:00 vlg Exp $
//------------------------------------------------------------------------------
// FileLogger.h
//------------------------------------------------------------------------------
// Copyright (C) 1997-2002 Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
#ifndef FILE_LOGGER_H
#define FILE_LOGGER_H
#include <fstream>
#include <string>
#include <iostream>
#include "assa/Logger_Impl.h"
namespace ASSA {
class FileLogger : public Logger_Impl
{
public:
FileLogger ();
virtual int log_open (const char* logfname_,
u_long groups_,
u_long maxsize_ = 10485760); // 10 Mb = 1024x1024x10
virtual int log_close (void);
virtual void log_resync (void);
virtual int log_msg (Group g_,
size_t indent_level_,
const string& func_name_,
size_t expected_sz_,
const char* fmt_, va_list);
virtual int log_func (Group g_,
size_t indent_level_,
const string& func_name_,
marker_t type_);
int log_raw_msg (const string& msg_);
void dump (void);
private:
enum state_t { opened, closed };
FileLogger (const FileLogger&); // copy constructor
FileLogger& operator= (const FileLogger&); // copy assignment
int handle_rollover ();
private:
std::ofstream m_sink;
u_long m_maxsize;
state_t m_state;
u_long m_bytecount;
};
inline FileLogger::
FileLogger ()
: m_maxsize (1048576),
m_state (closed),
m_bytecount (0)
{
/*--- empty ---*/
}
inline void
FileLogger::
log_resync (void)
{
m_sink << std::flush;
}
} // end namespace ASSA
#endif /* FILE_LOGGER_H */
Logger_Impl.h
u_long
unsigned long u_long
Definition Logger_Impl.h:41
ASSA::FileLogger::FileLogger
FileLogger()
Definition FileLogger.h:75
ASSA::FileLogger::handle_rollover
int handle_rollover()
Definition FileLogger.cpp:199
ASSA::FileLogger::dump
void dump(void)
Definition FileLogger.cpp:235
ASSA::FileLogger::log_func
virtual int log_func(Group g_, size_t indent_level_, const string &func_name_, marker_t type_)
Definition FileLogger.cpp:162
ASSA::FileLogger::log_open
virtual int log_open(const char *logfname_, u_long groups_, u_long maxsize_=10485760)
Open File Logger.
Definition FileLogger.cpp:33
ASSA::FileLogger::log_close
virtual int log_close(void)
Definition FileLogger.cpp:70
ASSA::FileLogger::FileLogger
FileLogger(const FileLogger &)
ASSA::FileLogger::log_msg
virtual int log_msg(Group g_, size_t indent_level_, const string &func_name_, size_t expected_sz_, const char *fmt_, va_list)
If output string is longer then LOGGER_MAXLINE-1, it is truncated to that size.
Definition FileLogger.cpp:117
ASSA::FileLogger::state_t
state_t
Definition FileLogger.h:60
ASSA::FileLogger::closed
@ closed
Definition FileLogger.h:60
ASSA::FileLogger::opened
@ opened
Definition FileLogger.h:60
ASSA::FileLogger::log_resync
virtual void log_resync(void)
Definition FileLogger.h:85
ASSA::FileLogger::m_maxsize
u_long m_maxsize
Definition FileLogger.h:69
ASSA::FileLogger::m_sink
std::ofstream m_sink
Definition FileLogger.h:68
ASSA::FileLogger::m_state
state_t m_state
Definition FileLogger.h:70
ASSA::FileLogger::log_raw_msg
int log_raw_msg(const string &msg_)
Log message as it is (raw) without indentation or timestamping, but still perform byte counting and t...
Definition FileLogger.cpp:184
ASSA::FileLogger::m_bytecount
u_long m_bytecount
Definition FileLogger.h:71
ASSA::FileLogger::operator=
FileLogger & operator=(const FileLogger &)
ASSA::Logger_Impl::Logger_Impl
Logger_Impl()
Definition Logger_Impl.h:253
ASSA
Definition Acceptor.h:40
ASSA::marker_t
marker_t
Definition LogMask.h:67
ASSA::Group
Group
Definition LogMask.h:25