[go: up one dir, main page]

File: tologger.h

package info (click to toggle)
tora 2.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 27,560 kB
  • ctags: 21,885
  • sloc: cpp: 189,278; sh: 17,561; makefile: 692; python: 159; xml: 69; ansic: 56
file content (60 lines) | stat: -rw-r--r-- 1,518 bytes parent folder | download
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

#ifndef __TORA_LOGGER__
#define __TORA_LOGGER__

#define USE_QT_THREAD_MANAGER 
#include "ts_log/critical_section.h"
#include "ts_log/message_handler_log.h"
#include "ts_log/thread_safe_log.h"
#include "ts_log/ts_log_utils.h"
#include "ts_log/decorator.h"

#include <iostream>

typedef Tdecorator<
	TSLOG_TYPELIST_6(dashDecorator<4>,
			 tidDecorator<qt_thread_manager>,
			 charDecorator<' '>,
			 hereDecorator, 
			 dashDecorator<4>,
			 charDecorator<'\n'>
		)> toDecorator;

template< int idxLog>
thread_safe_log templ_get_log_ownthread( int_to_type< idxLog> * = NULL )
{
	/* static std::ofstream out( get_out_name< idxLog>( false).c_str() ); */
	static internal_thread_safe_log_ownthread log( std::cout );
	return thread_safe_log( log);
}

/*
thread_safe_log templ_get_log_ownthread<1>( int_to_type< 1> * = NULL )
{
	static std::ofstream out( get_out_name< idxLog>( false).c_str() );
	static internal_thread_safe_log_ownthread log( out);
	return thread_safe_log( log);
}
*/

inline thread_safe_log get_log( int idxLog)
{
	switch( idxLog)
	{
	case 0: return templ_get_log_ownthread< 0>(); // tooracleconnection log
	case 1: return templ_get_log_ownthread< 1>(); // exception log
	case 2: return templ_get_log_ownthread< 2>(); // qDebug log
	default: assert( false);
	}
}

// TODO add some comment on this MSVC
inline std::ostream& operator<<( std::ostream & stream, const QString & str)
{ // TODO review this
	QByteArray b( str.toAscii());
	const char *c = b.constData();
	stream << c;
	return stream;
}

#endif