2
* Copyright 2010 Inalogic Inc.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3, as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the applicable version of the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of both the GNU Lesser General Public
15
* License version 3 along with this program. If not, see
16
* <http://www.gnu.org/licenses/>
18
* Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
28
// MessageBox resolves to:
29
// MessageBoxA, if UNICODE is not defined
30
// MessageBoxW, if UNICODE is defined
32
// In all cases in the code, it is assumed that we have UNICODE and _UNICODE defined or not.
33
// We have no support for cases of (UNICODE, !_UNICODE) or (!UNICODE, _UNICODE)
35
// char, if _UNICODE is not defined
36
// wchar_t, if _UNICODE is defined
39
// Set to true to disable the popping of dialog box. The message will go to the log.
40
const t_bool GNoDialog = false;
42
/*-----------------------------------------------------------------------------
43
Formatted printing and messages.
44
-----------------------------------------------------------------------------*/
46
t_u32 GetVariableArgs ( TCHAR *Dest, t_u32 Size, t_u32 Count, const TCHAR*& Fmt, va_list ArgPtr )
48
t_u32 Result = VSNTPRINTF_S (Dest, Size, Count, Fmt, ArgPtr);
52
t_u32 GetVariableArgsAnsi ( ANSICHAR *Dest, t_u32 Size, t_u32 Count, const ANSICHAR*& Fmt, va_list ArgPtr)
54
t_u32 Result = VSNPRINTF_S (Dest, Size, Count, Fmt, ArgPtr);
59
// This function can be used to print anything before the other output are initialized.
60
void PrintOutputDebugString (const TCHAR *Format, ... )
63
GET_VARARGS ( TempStr, 4096, NUX_ARRAY_COUNT (TempStr) - 1, Format );
66
OutputDebugString ( TempStr );
68
printf ("%s\n", TCHAR_TO_ANSI (TempStr) );
72
void LogOutputAssertMessage (const ANSICHAR *File, int Line, const TCHAR *Format/*=TEXT("")*/, ... )
75
GET_VARARGS ( TempStr, NUX_ARRAY_COUNT (TempStr), NUX_ARRAY_COUNT (TempStr) - 1, Format );
77
// Logged to a file... Put "\r\n" at the end of each line.
78
if (LogOutputRedirector::Ready() )
79
GLogDevice.LogFunction (NUX_MSG_SEVERITY_NONE, TEXT ("Assertion failed: %s\r\n [File:%s]\r\n [Line: %i]\r\n"), (const TCHAR *) TempStr, ANSI_TO_TCHAR (File), Line);
82
void LogOutputErrorMessage (const ANSICHAR *File, int Line, const TCHAR *Format/*=TEXT("")*/, ... )
85
GET_VARARGS ( TempStr, NUX_ARRAY_COUNT (TempStr), NUX_ARRAY_COUNT (TempStr) - 1, Format );
87
if (LogOutputRedirector::Ready() )
88
GLogDevice.LogFunction (NUX_MSG_SEVERITY_NONE, TEXT ("Error: %s\r\n [File:%s]\r\n [Line: %d]\r\n"), (const TCHAR *) TempStr, ANSI_TO_TCHAR (File), Line);
91
void LogOutputDebugMessage (const TCHAR *Format/*=TEXT("")*/, ... )
94
GET_VARARGS ( TempStr, NUX_ARRAY_COUNT (TempStr), NUX_ARRAY_COUNT (TempStr) - 1, Format );
96
if (LogOutputRedirector::Ready() )
97
GLogDevice.LogFunction (NUX_MSG_SEVERITY_NONE, TempStr);
100
void LogOutputSeverityMessage (int Severity, const TCHAR *Format/*=TEXT("")*/, ... )
103
GET_VARARGS ( TempStr, NUX_ARRAY_COUNT (TempStr), NUX_ARRAY_COUNT (TempStr) - 1, Format );
105
if (LogOutputRedirector::Ready() )
106
GLogDevice.LogFunction (Severity, TempStr);
109
bool OutputRedirectorReady()
111
return LogOutputRedirector::Ready();