libassa 3.5.1
Loading...
Searching...
No Matches
FileLogger.h
Go to the documentation of this file.
1// -*- c++ -*-
2//------------------------------------------------------------------------------
3// $Id: FileLogger.h,v 1.4 2005/10/08 02:42:00 vlg Exp $
4//------------------------------------------------------------------------------
5// FileLogger.h
6//------------------------------------------------------------------------------
7// Copyright (C) 1997-2002 Vladislav Grinchenko
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Library General Public
11// License as published by the Free Software Foundation; either
12// version 2 of the License, or (at your option) any later version.
13//------------------------------------------------------------------------------
14#ifndef FILE_LOGGER_H
15#define FILE_LOGGER_H
16
17#include <fstream>
18#include <string>
19#include <iostream>
20
21#include "assa/Logger_Impl.h"
22
23namespace ASSA {
24
30class FileLogger : public Logger_Impl
31{
32public:
33 FileLogger ();
34
35 virtual int log_open (const char* logfname_,
37 u_long maxsize_ = 10485760); // 10 Mb = 1024x1024x10
38
39 virtual int log_close (void);
40 virtual void log_resync (void);
41
42 virtual int log_msg (Group g_,
43 size_t indent_level_,
44 const string& func_name_,
45 size_t expected_sz_,
46 const char* fmt_, va_list);
47 virtual int log_func (Group g_,
48 size_t indent_level_,
49 const string& func_name_,
51
56 int log_raw_msg (const string& msg_);
57 void dump (void);
58
59private:
61
62 FileLogger (const FileLogger&); // copy constructor
63 FileLogger& operator= (const FileLogger&); // copy assignment
64
65 int handle_rollover ();
66
67private:
68 std::ofstream m_sink;
72};
73
75FileLogger ()
76 : m_maxsize (1048576),
77 m_state (closed),
78 m_bytecount (0)
79{
80 /*--- empty ---*/
81}
82
83inline void
85log_resync (void)
86{
87 m_sink << std::flush;
88}
89
90} // end namespace ASSA
91
92#endif /* FILE_LOGGER_H */
unsigned long u_long
Definition Logger_Impl.h:41
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
virtual int log_func(Group g_, size_t indent_level_, const string &func_name_, marker_t type_)
virtual int log_open(const char *logfname_, u_long groups_, u_long maxsize_=10485760)
Open File Logger.
virtual int log_close(void)
FileLogger(const FileLogger &)
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.
virtual void log_resync(void)
Definition FileLogger.h:85
std::ofstream m_sink
Definition FileLogger.h:68
int log_raw_msg(const string &msg_)
Log message as it is (raw) without indentation or timestamping, but still perform byte counting and t...
FileLogger & operator=(const FileLogger &)
marker_t
Definition LogMask.h:67
Group
Definition LogMask.h:25