11 |
// |
// |
12 |
// $Id$ |
// $Id$ |
13 |
// $Log$ |
// $Log$ |
14 |
|
// Revision 1.5 2004/12/26 08:03:34 skunix |
15 |
|
// changed lambda::bind's to boost::binds |
16 |
|
// |
17 |
// Revision 1.4 2004/12/26 07:50:33 skunix |
// Revision 1.4 2004/12/26 07:50:33 skunix |
18 |
// fixed Stream error, added a buffered Stream2 class, and added Level prefixing |
// fixed Stream error, added a buffered Stream2 class, and added Level prefixing |
19 |
// |
// |
36 |
#include <list> |
#include <list> |
37 |
|
|
38 |
#include <map> |
#include <map> |
39 |
#include <boost/lambda/bind.hpp> |
#include <boost/bind.hpp> |
40 |
#include <boost/format.hpp> |
#include <boost/format.hpp> |
41 |
#include <boost/shared_ptr.hpp> |
#include <boost/shared_ptr.hpp> |
42 |
#include <boost/thread.hpp> |
#include <boost/thread.hpp> |
43 |
|
#include <boost/thread/mutex.hpp> |
44 |
namespace usata |
namespace usata |
45 |
{ |
{ |
46 |
namespace log |
namespace log |
96 |
typedef std::list<Target *> TargetList; |
typedef std::list<Target *> TargetList; |
97 |
typedef std::map<int,std::string> PrefixMap; |
typedef std::map<int,std::string> PrefixMap; |
98 |
PrefixMap prefixes; |
PrefixMap prefixes; |
99 |
|
boost::mutex targets_mutex; |
100 |
TargetList targets; |
TargetList targets; |
101 |
int level; |
int level; |
102 |
|
|
103 |
}; |
}; |
104 |
|
|
105 |
Server::Server() |
Server::Server() |
111 |
|
|
112 |
Server::~Server() |
Server::~Server() |
113 |
{ |
{ |
114 |
using namespace boost::lambda; |
using boost::bind; |
115 |
std::for_each(impl->targets.begin(), impl->targets.end(), |
std::for_each(impl->targets.begin(), impl->targets.end(), |
116 |
bind(&Target::die, _1)); |
bind(&Target::die, _1)); |
117 |
} |
} |
139 |
|
|
140 |
if (pit != impl->prefixes.end()) |
if (pit != impl->prefixes.end()) |
141 |
{ |
{ |
142 |
using namespace boost::lambda; |
using boost::bind; |
143 |
std::string nmessage = (boost::format("%1% - %2%") % pit->second % message).str(); |
std::string nmessage = (boost::format("%1% - %2%") % pit->second % message).str(); |
144 |
std::for_each(impl->targets.begin(), impl->targets.end(), |
std::for_each(impl->targets.begin(), impl->targets.end(), |
145 |
bind(&Target::write, _1, nmessage)); |
bind(&Target::write, _1, nmessage)); |
146 |
} |
} |
147 |
else |
else |
148 |
{ |
{ |
149 |
using namespace boost::lambda; |
using boost::bind; |
150 |
std::for_each(impl->targets.begin(), impl->targets.end(), |
std::for_each(impl->targets.begin(), impl->targets.end(), |
151 |
bind(&Target::write, _1, message)); |
bind(&Target::write, _1, message)); |
152 |
|
|
168 |
void |
void |
169 |
Server::commit() |
Server::commit() |
170 |
{ |
{ |
171 |
using namespace boost::lambda; |
using boost::bind; |
172 |
std::for_each(impl->targets.begin(), impl->targets.end(), |
std::for_each(impl->targets.begin(), impl->targets.end(), |
173 |
bind(&Target::commit, _1)); |
bind(&Target::commit, _1)); |
174 |
} |
} |