Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
ITABase
Commits
446d407e
Commit
446d407e
authored
Aug 13, 2016
by
Dipl.-Ing. Jonas Stienen
Browse files
Adding ITALog
parent
02c7e292
Changes
3
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
446d407e
...
...
@@ -58,6 +58,7 @@ set( ITABaseHeader
"include/ITAHDFTSpectrum.h"
"include/ITAFunctors.h"
"include/ITAHPT.h"
"include/ITALog.h"
"include/ITAMutex.h"
"include/ITANumericUtils.h"
"include/ITASampleBuffer.h"
...
...
@@ -86,6 +87,7 @@ set( ITABaseSources
"src/ITAFileSystemUtils.cpp"
"src/ITAHDFTSpectrum.cpp"
"src/ITAHPT.cpp"
"src/ITALog.cpp"
"src/ITAMutex.cpp"
"src/ITANumericUtils.cpp"
"src/ITASampleBuffer.cpp"
...
...
include/ITALog.h
0 → 100644
View file @
446d407e
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2016
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_LOG
#define INCLUDE_WATCHER_ITA_LOG
//! Ausgabe-Direktiven
enum
{
ITALOG_OUTPUT_CONSOLE
=
0
,
//!< Log to stdout, stderr
ITALOG_OUTPUT_MSVC
=
1
//!< Log to the Visual Studio console ("OutputDebugString")
};
//! Log-Stufen
enum
{
ITALOG_QUIET
=
0
,
//!< Stumm
ITALOG_ERROR
=
1
,
//!< Fehler
ITALOG_WARN
=
2
,
//!< Warnung
ITALOG_INFO
=
3
,
//!< Information
ITALOG_TRACE
=
4
//!< Gesprächig
};
//! Flags
const
int
ITALOG_MODULENAME
=
1
<<
0
;
const
int
ITALOG_SHORTNAME
=
1
<<
1
;
const
int
ITALOG_LEVELINFO
=
1
<<
2
;
const
int
ITALOG_TIMESTAMP
=
1
<<
3
;
//! Ausgabe-Funktionen
void
ITA_BASE_API
italog_printf
(
const
char
*
pszModuleName
,
int
iFlags
,
const
char
*
format
...);
void
ITA_BASE_API
italog_msvc
(
const
char
*
pszModuleName
,
int
iFlags
,
const
char
*
format
...
);
// --= Makros für verschiedene Ausgabeversionen mit mehr oder weniger Parametern =--
//! Einfache Ausgabe ohne weitere Argumente
#define ITALOG_PRINTF0(...) { italog_printf("", 0, __VA_ARGS__); }
#define ITALOG_PRINTF1(SHORTNAME, ...) { italog_printf(SHORTNAME, ITALOG_SHORTNAME, __VA_ARGS__); }
#define ITALOG_PRINTF2(MODULENAME, ...) { italog_printf(MODULENAME, ITALOG_MODULENAME, __VA_ARGS__); }
#define ITALOG_PRINTF9(MODULE, NAME, SHORTNAME, FLAGS, LOGLEVEL, LOGTYPE, ...) { if(LOGLEVEL >= LOGTYPE) { italog_printf(MODULENAME, FLAGS, __VA_ARGS__); } }
#define ITALOG_MSVC0(...) { italog_msvc("", 0, __VA_ARGS__); }
#define ITALOG_MSVC1(SHORTNAME, ...) { italog_msvc(SHORTNAME, ITALOG_SHORTNAME, __VA_ARGS__); }
#endif // INCLUDE_WATCHER_ITA_LOG
src/ITALog.cpp
0 → 100644
View file @
446d407e
#include
<ITALog.h>
#include
<ITACriticalSection.h>
#include
<stdarg.h>
#include
<stdio.h>
#include
<string>
#ifdef WIN32
#include
<windows.h>
#endif
#define DEBUG_PRINTF_BUFSIZE 16384
static
ITACriticalSection
g_csDebugPrintf
;
static
char
g_pszDebugPrintfBuf
[
DEBUG_PRINTF_BUFSIZE
];
void
italog_printf
(
const
char
*
pszModuleName
,
int
iFlags
,
const
char
*
format
...)
{
std
::
string
sCombinedPreamble
=
""
;
if
(
iFlags
&
(
ITALOG_MODULENAME
+
ITALOG_SHORTNAME
))
{
sCombinedPreamble
+=
pszModuleName
;
sCombinedPreamble
+=
": "
;
}
// Source: VADebug by fwe
va_list
args
;
va_start
(
args
,
format
);
#ifdef WIN32
printf_s
(
"%s"
,
sCombinedPreamble
.
c_str
());
#else
printf
(
"%s"
,
sCombinedPreamble
.
c_str
());
#endif
vfprintf
(
stdout
,
format
,
args
);
va_end
(
args
);
return
;
};
#ifdef WIN32
void
italog_msvc
(
const
char
*
pszModuleName
,
int
iFlags
,
const
char
*
format
...)
{
g_csDebugPrintf
.
enter
();
int
pos
=
0
;
if
(
iFlags
&
(
ITALOG_MODULENAME
+
ITALOG_SHORTNAME
))
pos
=
sprintf_s
(
g_pszDebugPrintfBuf
,
DEBUG_PRINTF_BUFSIZE
,
"%s: "
,
pszModuleName
);
va_list
args
;
va_start
(
args
,
format
);
vsprintf_s
(
g_pszDebugPrintfBuf
+
pos
,
DEBUG_PRINTF_BUFSIZE
-
pos
,
format
,
args
);
va_end
(
args
);
OutputDebugStringA
(
g_pszDebugPrintfBuf
);
g_csDebugPrintf
.
leave
();
return
;
}
#endif
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment