2
This file is a part of the NVDA project.
3
URL: http://www.nvda-project.org/
4
Copyright 2006-2010 NVDA contributers.
5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License version 2.0, as published by
7
the Free Software Foundation.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
This license can be found at:
12
http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
1
15
#ifndef NVDAHELPER_LOG_H
2
16
#define NVDAHELPER_LOG_H
7
#define __STR2WSTR(x) L##x
8
#define _STR2WSTR(x) __STR2WSTR(x)
10
#define _LOG_MSG(level,message) {\
11
std::wostringstream* s = new std::wostringstream;\
13
nvdaControllerInternal_logMessage(GetCurrentProcessId(),GetCurrentThreadId(),level,_STR2WSTR(__FILE__),_STR2WSTR(__FUNCTION__),__LINE__,s->str().c_str());\
20
#include <common/lock.h>
22
#define nhAssert _ASSERTE
24
void logMessage(int level, const wchar_t* msg);
26
int NVDALogCrtReportHook(int reportType, const wchar_t* msg, int* returnVal);
17
28
#define loglevel_none 60
18
#define loglevel_critical 50
29
#define LOGLEVEL_CRITICAL 50
19
30
#define LOGLEVEL_ERROR 40
20
31
#define LOGLEVEL_WARNING 30
21
32
#define LOGLEVEL_INFO 20
22
33
#define LOGLEVEL_DEBUGWARNING 15
23
34
#define LOGLEVEL_DEBUG 10
36
#define __STR2WSTR(x) L##x
37
#define _STR2WSTR(x) __STR2WSTR(x)
39
static std::wostringstream _logStringStream;
40
static LockableObject _logLock;
42
#define _LOG_MSG_MACRO(level,message) {\
44
_logStringStream.str(L"");\
45
_logStringStream<<L"Thread "<<GetCurrentThreadId()<<L", "<<_STR2WSTR(__FILE__)<<L", "<<_STR2WSTR(__FUNCTION__)<<L", "<<__LINE__<<L":"<<std::endl<<message<<std::endl;\
46
logMessage(level,_logStringStream.str().c_str());\
26
51
#define LOGLEVEL LOGLEVEL_NONE
29
54
#if LOGLEVEL <= LOGLEVEL_CRITICAL
30
#define LOG_CRITICAL(message) _LOG_MSG(LOGLEVEL_CRITICAL,message)
55
#define LOG_CRITICAL(message) _LOG_MSG_MACRO(LOGLEVEL_CRITICAL,message)
32
57
#define LOG_CRITICAL(message)
35
60
#if LOGLEVEL <= LOGLEVEL_ERROR
36
#define LOG_ERROR(message) _LOG_MSG(LOGLEVEL_ERROR,message)
61
#define LOG_ERROR(message) _LOG_MSG_MACRO(LOGLEVEL_ERROR,message)
38
63
#define LOG_ERROR(message)
41
66
#if LOGLEVEL <= LOGLEVEL_WARNING
42
#define LOG_WARNING(message) _LOG_MSG(LOGLEVEL_WARNING,message)
67
#define LOG_WARNING(message) _LOG_MSG_MACRO(LOGLEVEL_WARNING,message)
44
69
#define LOG_WARNING(message)
47
72
#if LOGLEVEL <= LOGLEVEL_INFO
48
#define LOG_INFO(message) _LOG_MSG(LOGLEVEL_INFO,message)
73
#define LOG_INFO(message) _LOG_MSG_MACRO(LOGLEVEL_INFO,message)
50
75
#define LOG_INFO(message)
53
78
#if LOGLEVEL <= LOGLEVEL_DEBUGWARNING
54
#define LOG_DEBUGWARNING(message) _LOG_MSG(LOGLEVEL_DEBUGWARNING,message)
79
#define LOG_DEBUGWARNING(message) _LOG_MSG_MACRO(LOGLEVEL_DEBUGWARNING,message)
56
81
#define LOG_DEBUGWARNING(message)
59
84
#if LOGLEVEL <= LOGLEVEL_DEBUG
60
#define LOG_DEBUG(message) _LOG_MSG(LOGLEVEL_DEBUG,message)
85
#define LOG_DEBUG(message) _LOG_MSG_MACRO(LOGLEVEL_DEBUG,message)
62
87
#define LOG_DEBUG(message)