[164] | 1 | /* logging.h
|
---|
| 2 | *
|
---|
| 3 | * Copyright (C) 2006-2015 wolfSSL Inc.
|
---|
| 4 | *
|
---|
| 5 | * This file is part of wolfSSL. (formerly known as CyaSSL)
|
---|
| 6 | *
|
---|
| 7 | * wolfSSL is free software; you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * wolfSSL is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with this program; if not, write to the Free Software
|
---|
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
---|
| 20 | */
|
---|
| 21 |
|
---|
| 22 | /* submitted by eof */
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | #ifndef WOLFSSL_LOGGING_H
|
---|
| 26 | #define WOLFSSL_LOGGING_H
|
---|
| 27 |
|
---|
| 28 | #include <wolfssl/wolfcrypt/types.h>
|
---|
| 29 |
|
---|
| 30 | #ifdef __cplusplus
|
---|
| 31 | extern "C" {
|
---|
| 32 | #endif
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | enum CYA_Log_Levels {
|
---|
| 36 | ERROR_LOG = 0,
|
---|
| 37 | INFO_LOG,
|
---|
| 38 | ENTER_LOG,
|
---|
| 39 | LEAVE_LOG,
|
---|
| 40 | OTHER_LOG
|
---|
| 41 | };
|
---|
| 42 |
|
---|
| 43 | typedef void (*wolfSSL_Logging_cb)(const int logLevel,
|
---|
| 44 | const char *const logMessage);
|
---|
| 45 |
|
---|
| 46 | WOLFSSL_API int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb log_function);
|
---|
| 47 |
|
---|
| 48 | #ifdef DEBUG_WOLFSSL
|
---|
| 49 | /* a is prepended to m and b is appended, creating a log msg a + m + b */
|
---|
| 50 | #define WOLFSSL_LOG_CAT(a, m, b) #a " " m " " #b
|
---|
| 51 |
|
---|
| 52 | void WOLFSSL_ENTER(const char* msg);
|
---|
| 53 | void WOLFSSL_LEAVE(const char* msg, int ret);
|
---|
| 54 | #define WOLFSSL_STUB(m) \
|
---|
| 55 | WOLFSSL_MSG(WOLFSSL_LOG_CAT(wolfSSL Stub, m, not implemented))
|
---|
| 56 |
|
---|
| 57 | void WOLFSSL_ERROR(int);
|
---|
| 58 | void WOLFSSL_MSG(const char* msg);
|
---|
| 59 |
|
---|
| 60 | #else /* DEBUG_WOLFSSL */
|
---|
| 61 |
|
---|
| 62 | #define WOLFSSL_ENTER(m)
|
---|
| 63 | #define WOLFSSL_LEAVE(m, r)
|
---|
| 64 | #define WOLFSSL_STUB(m)
|
---|
| 65 |
|
---|
| 66 | #define WOLFSSL_ERROR(e)
|
---|
| 67 | #define WOLFSSL_MSG(m)
|
---|
| 68 |
|
---|
| 69 | #endif /* DEBUG_WOLFSSL */
|
---|
| 70 |
|
---|
| 71 | #ifdef __cplusplus
|
---|
| 72 | }
|
---|
| 73 | #endif
|
---|
| 74 | #endif /* WOLFSSL_LOGGING_H */
|
---|
| 75 |
|
---|