-
Notifications
You must be signed in to change notification settings - Fork 294
/
trace_logger.hh
76 lines (58 loc) · 1.67 KB
/
trace_logger.hh
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
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// This file is part of khmer, http://github.com/ged-lab/khmer/, and is
// Copyright (C) Michigan State University, 2009-2013. It is licensed under
// the three-clause BSD license; see doc/LICENSE.txt.
// Contact: khmer-project@idyll.org
//
#ifndef TRACE_LOGGER_HH
#define TRACE_LOGGER_HH
#include <cstdarg>
#include <cstdio>
#include "khmer.hh"
namespace khmer
{
struct TraceLogger {
enum {
TLVL_ALL = 0,
TLVL_DEBUG9, TLVL_DEBUG8, TLVL_DEBUG7, TLVL_DEBUG6, TLVL_DEBUG5,
TLVL_DEBUG4, TLVL_DEBUG3, TLVL_DEBUG2, TLVL_DEBUG1, TLVL_DEBUG0,
TLVL_INFO9, TLVL_INFO8, TLVL_INFO7, TLVL_INFO6, TLVL_INFO5,
TLVL_INFO4, TLVL_INFO3, TLVL_INFO2, TLVL_INFO1, TLVL_INFO0,
TLVL_WARNING = 30,
TLVL_ERROR = 40,
TLVL_CRITICAL = 50,
TLVL_NONE = 255
};
#ifdef WITH_INTERNAL_TRACING
TraceLogger( uint8_t const level, FILE * stream_handle );
#endif
TraceLogger(
uint8_t const level, char const * const file_name_format, ...
);
~TraceLogger( );
inline void operator( )(
uint8_t const level, char const * const format, ...
) const
#ifdef WITH_INTERNAL_TRACING
{
va_list varargs;
if (_level <= level) {
va_start( varargs, format );
vfprintf( _stream_handle, format, varargs );
va_end( varargs );
fflush( _stream_handle );
}
}
#else // WITH_INTERNAL_TRACING
{ }
#endif // !WITH_INTERNAL_TRACING
private:
#ifdef WITH_INTERNAL_TRACING
bool _shared_stream;
uint8_t _level;
FILE * _stream_handle;
#endif
};
} // namespace khmer
#endif // TRACE_LOGGER_HH
// vim: set ft=cpp sts=4 sw=4 tw=80: