ssh

Dependents:   OS

Committer:
sPymbed
Date:
Mon Nov 25 14:24:05 2019 +0000
Revision:
0:c4152c628df5
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sPymbed 0:c4152c628df5 1 /* log.h
sPymbed 0:c4152c628df5 2 *
sPymbed 0:c4152c628df5 3 * Copyright (C) 2014-2016 wolfSSL Inc.
sPymbed 0:c4152c628df5 4 *
sPymbed 0:c4152c628df5 5 * This file is part of wolfSSH.
sPymbed 0:c4152c628df5 6 *
sPymbed 0:c4152c628df5 7 * wolfSSH is free software; you can redistribute it and/or modify
sPymbed 0:c4152c628df5 8 * it under the terms of the GNU General Public License as published by
sPymbed 0:c4152c628df5 9 * the Free Software Foundation; either version 3 of the License, or
sPymbed 0:c4152c628df5 10 * (at your option) any later version.
sPymbed 0:c4152c628df5 11 *
sPymbed 0:c4152c628df5 12 * wolfSSH is distributed in the hope that it will be useful,
sPymbed 0:c4152c628df5 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
sPymbed 0:c4152c628df5 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
sPymbed 0:c4152c628df5 15 * GNU General Public License for more details.
sPymbed 0:c4152c628df5 16 *
sPymbed 0:c4152c628df5 17 * You should have received a copy of the GNU General Public License
sPymbed 0:c4152c628df5 18 * along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
sPymbed 0:c4152c628df5 19 */
sPymbed 0:c4152c628df5 20
sPymbed 0:c4152c628df5 21
sPymbed 0:c4152c628df5 22 /*
sPymbed 0:c4152c628df5 23 * The log module contains the interface to the logging function. When
sPymbed 0:c4152c628df5 24 * debugging is enabled and turned on, the logger will output to STDOUT.
sPymbed 0:c4152c628df5 25 * A custom logging callback may be installed.
sPymbed 0:c4152c628df5 26 */
sPymbed 0:c4152c628df5 27
sPymbed 0:c4152c628df5 28
sPymbed 0:c4152c628df5 29 #pragma once
sPymbed 0:c4152c628df5 30
sPymbed 0:c4152c628df5 31 #include <wolfssh/settings.h>
sPymbed 0:c4152c628df5 32
sPymbed 0:c4152c628df5 33 #ifdef __cplusplus
sPymbed 0:c4152c628df5 34 extern "C" {
sPymbed 0:c4152c628df5 35 #endif
sPymbed 0:c4152c628df5 36
sPymbed 0:c4152c628df5 37
sPymbed 0:c4152c628df5 38 enum wolfSSH_LogLevel {
sPymbed 0:c4152c628df5 39 WS_LOG_USER = 5,
sPymbed 0:c4152c628df5 40 WS_LOG_ERROR = 4,
sPymbed 0:c4152c628df5 41 WS_LOG_WARN = 3,
sPymbed 0:c4152c628df5 42 WS_LOG_INFO = 2,
sPymbed 0:c4152c628df5 43 WS_LOG_DEBUG = 1,
sPymbed 0:c4152c628df5 44 WS_LOG_DEFAULT = WS_LOG_DEBUG
sPymbed 0:c4152c628df5 45 };
sPymbed 0:c4152c628df5 46
sPymbed 0:c4152c628df5 47
sPymbed 0:c4152c628df5 48 typedef void (*wolfSSH_LoggingCb)(enum wolfSSH_LogLevel,
sPymbed 0:c4152c628df5 49 const char *const logMsg);
sPymbed 0:c4152c628df5 50 WOLFSSH_API void wolfSSH_SetLoggingCb(wolfSSH_LoggingCb logF);
sPymbed 0:c4152c628df5 51 WOLFSSH_API int wolfSSH_LogEnabled(void);
sPymbed 0:c4152c628df5 52
sPymbed 0:c4152c628df5 53
sPymbed 0:c4152c628df5 54 #ifdef __GNUC__
sPymbed 0:c4152c628df5 55 #define FMTCHECK __attribute__((format(printf,2,3)))
sPymbed 0:c4152c628df5 56 #else
sPymbed 0:c4152c628df5 57 #define FMTCHECK
sPymbed 0:c4152c628df5 58 #endif /* __GNUC__ */
sPymbed 0:c4152c628df5 59
sPymbed 0:c4152c628df5 60
sPymbed 0:c4152c628df5 61 WOLFSSH_API void wolfSSH_Log(enum wolfSSH_LogLevel,
sPymbed 0:c4152c628df5 62 const char *const, ...) FMTCHECK;
sPymbed 0:c4152c628df5 63
sPymbed 0:c4152c628df5 64 #define WLOG(...) do { \
sPymbed 0:c4152c628df5 65 if (wolfSSH_LogEnabled()) \
sPymbed 0:c4152c628df5 66 wolfSSH_Log(__VA_ARGS__); \
sPymbed 0:c4152c628df5 67 } while (0)
sPymbed 0:c4152c628df5 68
sPymbed 0:c4152c628df5 69
sPymbed 0:c4152c628df5 70 #ifdef __cplusplus
sPymbed 0:c4152c628df5 71 }
sPymbed 0:c4152c628df5 72 #endif
sPymbed 0:c4152c628df5 73