Debian Codegraph @

include/toollog.h

raw symbols SCIP
1 // ****************************************************************************
2 // Project: libguytools
3 // ****************************************************************************
4 // Programmer: Guy Voncken
5 // Police Grand-Ducale
6 // Service de Police Judiciaire
7 // Section Nouvelles Technologies
8 // ****************************************************************************
9 // Module: Log utility
10 // ****************************************************************************
11
12 // Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
13 // 2018, 2019
14 // Guy Voncken
15 //
16 // This file is part of libguytools.
17 //
18 // libguytools is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 // libguytools is distributed in the hope that it will be useful,
24 // but WITHOUT ANY WARRANTY; without even the implied warranty of
25 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 // GNU General Public License for more details.
27 //
28 // You should have received a copy of the GNU General Public License
29 // along with libguytools. If not, see <http://www.gnu.org/licenses/>.
30
31 #ifndef __LOG_H__
32 #define __LOG_H__
33
34 class t_Log
35 {
36 public:
37 typedef enum
38 {
39 Debug=0,
40 Info,
41 Error,
42
43 Entries // must always be the last element in the list
44 } t_Level;
45
46
47 t_Log (const char* pFileName, APIRET &rc);
48 ~t_Log (void);
49
50 static bool IsInitialised (void);
51 static void GetLibGuyToolsVersion (const char **pVersion);
52
53 static void vEntry (t_Level Level, const char *pFileName, const char *pFunctionName, int LineNr, const char *pFormat, va_list pArguments);
54 static void Entry (t_Level Level, const char *pFileName, const char *pFunctionName, int LineNr, const char *pFormat, ...) __attribute__ ((format (printf, 5, 6)));
55 static void vEntryDebug (const char *pFileName, const char *pFunctionName, int LineNr, const char *pFormat, va_list pArguments);
56 static void vEntryInfo (const char *pFileName, const char *pFunctionName, int LineNr, const char *pFormat, va_list pArguments);
57 static void vEntryError (const char *pFileName, const char *pFunctionName, int LineNr, const char *pFormat, va_list pArguments);
58
59 #define LOG_DEBUG(...) t_Log::Entry (t_Log::Debug, __FFL__, __VA_ARGS__);
60 #define LOG_INFO(...) t_Log::Entry (t_Log::Info , __FFL__, __VA_ARGS__);
61 #define LOG_ERROR(...) t_Log::Entry (t_Log::Error, __FFL__, __VA_ARGS__);
62
63 // Possible error codes
64 // --------------------
65 static const APIRET TOOLLOG_ERROR_INITIALISED_TWICE = ERROR_BASE_TOOL_LOG + 1;
66 static const APIRET TOOLLOG_ERROR_HOSTNAME_TOO_LONG = ERROR_BASE_TOOL_LOG + 2;
67 };
68
69 #endif
70