eid-viewer
eid-viewer library
Loading...
Searching...
No Matches
logtest.h
1
2/* ****************************************************************************
3
4 * eID Middleware Project.
5 * Copyright (C) 2014 FedICT.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License version
9 * 3.0 as published by the Free Software Foundation.
10 *
11 * This software is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this software; if not, see
18 * http://www.gnu.org/licenses/.
19
20**************************************************************************** */
21
22#ifndef logtest_h
23#define logtest_h
24
25#include <stdio.h>
26
27
28/****************************************************************************
29 * Logging definitions
30 ***************************************************************************/
31typedef enum pkcs11test_log_level
32{ LVL_DEBUG = 0, LVL_INFO, LVL_WARNING, LVL_ERROR, LVL_NOLEVEL
33} PKCS11TEST_LOG_LEVEL;
34 static PKCS11TEST_LOG_LEVEL g_logLevel = LVL_DEBUG;
35
36
37
38/****************************************************************************
39 * Logging macro's
40 ***************************************************************************/
41#define pkcs11test_filename "test_pkcs11.log"
42
43/****************************************************************************
44 * macro's for logging to file
45 ***************************************************************************/
46//#define testlog(LOGLEVEL,...) logPrefix(LOGLEVEL), fprintf(pkcs11test_logfile, __VA_ARGS__)
47//#define printlogprefic(LOGLEVEL,LOGPREFIX) fprintf(LOGLEVEL,LOGPREFIX)
48
49
50/****************************************************************************
51 * macro's for logging to stdout
52 ***************************************************************************/
53#define testlog(LOGLEVEL,...) if (LOGLEVEL >= g_logLevel) {logPrefix(LOGLEVEL); printf(__VA_ARGS__);}
54#define printlogprefic(LOGLEVEL,LOGPREFIX) printf(LOGPREFIX)
55
56
57/****************************************************************************
58 * Log Function global variables
59 ***************************************************************************/
60 FILE * pkcs11test_logfile;
61
62
63/****************************************************************************
64 * Log Function prototypes
65 ***************************************************************************/
66 errno_t initLog();
67void endLog();
68 void logPrefix(PKCS11TEST_LOG_LEVEL level);
69void testlogbytes(PKCS11TEST_LOG_LEVEL loglevel, unsigned char *pValue,
70 unsigned long ulValueLen);
71
72#endif /* */