openModeller
Version 1.5.0
Main Page
Modules
Classes
Files
File List
File Members
Log.hh
Go to the documentation of this file.
1
28
#ifndef _LOGHH_
29
#define _LOGHH_
30
31
#include <
openmodeller/os_specific.hh
>
32
#include <
openmodeller/om_defs.hh
>
33
34
#include <iostream>
35
#include <fstream>
36
#include <string>
37
#include <stdarg.h>
38
#include <stdio.h>
39
40
/****************************************************************/
41
/****************************** Log *****************************/
42
48
class
dllexp
Log
49
{
50
public
:
52
static
Log
* instance();
53
54
typedef
enum
{
55
Debug =0,
56
Default =1,
57
Info =2,
58
Warn =3,
59
Error =4
60
} Level;
61
62
#ifndef SWIG
63
class
LogCallback
{
64
public
:
65
virtual
~LogCallback
(){};
66
virtual
void
operator()(
Level
level,
const
std::string& msg ) = 0;
67
};
68
69
class
OstreamCallback
:
public
LogCallback
{
70
public
:
71
OstreamCallback
( std::ostream& os );
72
void
operator()(
Level
level,
const
std::string& msg );
73
private
:
74
std::ostream&
os
;
75
};
76
#endif
77
78
protected
:
82
Log
( );
83
84
public
:
85
87
static
std::string format(
const
char
*fmt, ... );
88
89
~
Log
();
90
97
void
set(
Level
level, std::string fileName,
char
const
*pref=
""
);
98
104
void
setCallback(
LogCallback
*lc );
105
107
void
setLevel
(
Level
level ) { _level = level; }
108
110
void
setPrefix(
const
char
*pref );
111
112
void
debug(
const
char
*format, ... );
113
void
info (
const
char
*format, ... );
114
void
warn (
const
char
*format, ... );
115
void
error
(
const
char
*format, ... );
116
118
void
operator()(
const
char
*format, ... );
119
120
private
:
121
122
//write log out to callback
123
void
FormatAndWrite(
Log::LogCallback
& lc,
Log::Level
level, std::string pref,
const
char
* format, va_list ap );
124
125
static
Log
*
mpInstance
;
126
127
LogCallback
*
callback
;
128
129
Level
_level
;
130
131
std::string
_pref
;
132
133
bool
_deleteCallback
;
// flag indicating if the callback should be deleted by Log
134
};
135
136
#endif
137
om_defs.hh
Log::_level
Level _level
Definition:
Log.hh:129
Log
Definition:
Log.hh:48
Log::_deleteCallback
bool _deleteCallback
Definition:
Log.hh:133
Log::_pref
std::string _pref
Definition:
Log.hh:131
Log::Level
Level
Definition:
Log.hh:54
Log::setLevel
void setLevel(Level level)
Definition:
Log.hh:107
Log::callback
LogCallback * callback
Definition:
Log.hh:127
Log::LogCallback
Definition:
Log.hh:63
Log::OstreamCallback::os
std::ostream & os
Definition:
Log.hh:74
Log::mpInstance
static Log * mpInstance
Definition:
Log.hh:125
os_specific.hh
Log::LogCallback::~LogCallback
virtual ~LogCallback()
Definition:
Log.hh:65
Log::OstreamCallback
Definition:
Log.hh:69
error
static char error[256]
Definition:
FileParser.cpp:42
src
openmodeller
Log.hh
Generated on Thu Jan 8 2015 17:05:09 for openModeller by
1.8.6