Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
blaze
util
logging
Logger.h
Go to the documentation of this file.
1
//=================================================================================================
20
//=================================================================================================
21
22
#ifndef _BLAZE_UTIL_LOGGING_LOGGER_H_
23
#define _BLAZE_UTIL_LOGGING_LOGGER_H_
24
25
26
//*************************************************************************************************
27
// Includes
28
//*************************************************************************************************
29
30
#include <fstream>
31
#include <boost/thread/mutex.hpp>
32
#include <
blaze/util/singleton/Singleton.h
>
33
#include <
blaze/util/SystemClock.h
>
34
35
36
namespace
blaze {
37
38
namespace
logging {
39
40
//=================================================================================================
41
//
42
// CLASS DEFINITION
43
//
44
//=================================================================================================
45
46
//*************************************************************************************************
64
class
Logger
:
private
Singleton
<Logger,SystemClock>
65
{
66
private
:
67
//**Constructors********************************************************************************
70
explicit
Logger
();
72
//**********************************************************************************************
73
74
public
:
75
//**Destructor**********************************************************************************
78
~Logger
();
80
//**********************************************************************************************
81
82
private
:
83
//**Logging functions***************************************************************************
86
template
<
typename
Type >
void
log
(
const
Type& message );
88
//**********************************************************************************************
89
90
//**Utility functions***************************************************************************
93
void
openLogFile
();
95
//**********************************************************************************************
96
97
//**Member variables****************************************************************************
100
boost::mutex
mutex_
;
101
std::ofstream
log_
;
102
103
//**********************************************************************************************
104
105
//**Friend declarations*************************************************************************
107
friend
class
FunctionTrace
;
108
friend
class
LogSection
;
109
BLAZE_BEFRIEND_SINGLETON
;
111
//**********************************************************************************************
112
};
113
//*************************************************************************************************
114
115
116
117
118
//=================================================================================================
119
//
120
// LOGGING FUNCTIONS
121
//
122
//=================================================================================================
123
124
//*************************************************************************************************
133
template
<
typename
Type >
// Type of the log message
134
void
Logger::log
(
const
Type& message )
135
{
136
boost::mutex::scoped_lock lock(
mutex_
);
137
if
( !
log_
.is_open() )
138
openLogFile
();
139
log_
<< message;
140
log_
.flush();
141
}
142
//*************************************************************************************************
143
144
}
// namespace logging
145
146
}
// namespace blaze
147
148
#endif
Generated on Fri May 24 2013 16:39:57 by
1.8.3.1