-
Notifications
You must be signed in to change notification settings - Fork 155
/
logger.cpp
64 lines (51 loc) · 1.59 KB
/
logger.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2005, 2006
// Seweryn Habdank-Wojewodzki
// Distributed under the Boost Software License,
// Version 1.0.
// (copy at http://www.boost.org/LICENSE_1_0.txt)
#include "logger.h"
#if !defined(CLEANLOG)
#define FTLOG
#if !defined(DEBUG)
#undef FTLOG
#undef TLOG
#endif
//#if defined (FTLOG)
//#include <fstream>
//#else
#include <iostream>
// http://www.msobczak.com/prog/bin/nullstream.zip
#include "nullstream.h"
//#endif
logger_t::logger_t()
{}
bool logger_t::is_activated = true;
#if defined(TLOG)
std::unique_ptr<std::ostream> logger_t::outstream_helper_ptr
= std::unique_ptr<std::ostream>( new NullStream );
std::ostream * logger_t::outstream = &std::cout;
#elif defined (ETLOG)
std::unique_ptr<std::ostream> logger_t::outstream_helper_ptr
= std::unique_ptr <std::ostream>( new NullStream );
std::ostream * logger_t::outstream = &std::cerr;
#elif defined (FTLOG)
//std::unique_ptr <std::ostream> logger_t::outstream_helper_ptr
//= std::unique_ptr<std::ostream>( new std::ofstream ("oldlogger.txt"));
//std::ostream * logger_t::outstream = outstream_helper_ptr.get();
std::unique_ptr<std::ostream> logger_t::outstream_helper_ptr
= std::unique_ptr <std::ostream>( new NullStream );
std::ostream * logger_t::outstream = &std::cout;
// here is a place for user defined output stream
// and compiler flag
#else
std::unique_ptr<std::ostream> logger_t::outstream_helper_ptr
= std::unique_ptr<std::ostream>( new NullStream );
std::ostream* logger_t::outstream = outstream_helper_ptr.get();
#endif
logger_t & logger()
{
static logger_t* ans = new logger_t();
return *ans;
}
#endif
// !CLEANLOG