3 * Copyright (C) 2006-2014 wolfSSL Inc.
5 * This file is part of CyaSSL.
7 * CyaSSL 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.
12 * CyaSSL 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.
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
26 #include <cyassl/ctaocrypt/settings.h>
28 /* submitted by eof */
30 #include <cyassl/ctaocrypt/logging.h>
31 #include <cyassl/ctaocrypt/error-crypt.h>
37 CYASSL_API int CyaSSL_Debugging_ON(void);
38 CYASSL_API void CyaSSL_Debugging_OFF(void);
46 /* Set these to default values initially. */
47 static CyaSSL_Logging_cb log_function = 0;
48 static int loggingEnabled = 0;
50 #endif /* DEBUG_CYASSL */
53 int CyaSSL_SetLoggingCb(CyaSSL_Logging_cb f)
66 return NOT_COMPILED_IN;
71 int CyaSSL_Debugging_ON(void)
77 return NOT_COMPILED_IN;
82 void CyaSSL_Debugging_OFF(void)
95 #include <stdio.h> /* for default printf stuff */
99 int dc_log_printf(char*, ...);
102 static void cyassl_log(const int logLevel, const char *const logMessage)
105 log_function(logLevel, logMessage);
107 if (loggingEnabled) {
109 dc_log_printf("%s\n", logMessage);
110 #elif defined(MICRIUM)
111 #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
112 NetSecure_TraceOut((CPU_CHAR *)logMessage);
114 #elif defined(CYASSL_MDK_ARM)
116 printf("%s\n", logMessage);
119 fprintf(stderr, "%s\n", logMessage);
126 void CYASSL_MSG(const char* msg)
129 cyassl_log(INFO_LOG , msg);
133 void CYASSL_ENTER(const char* msg)
135 if (loggingEnabled) {
137 sprintf(buffer, "CyaSSL Entering %s", msg);
138 cyassl_log(ENTER_LOG , buffer);
143 void CYASSL_LEAVE(const char* msg, int ret)
145 if (loggingEnabled) {
147 sprintf(buffer, "CyaSSL Leaving %s, return %d", msg, ret);
148 cyassl_log(LEAVE_LOG , buffer);
153 void CYASSL_ERROR(int error)
155 if (loggingEnabled) {
157 sprintf(buffer, "CyaSSL error occured, error = %d", error);
158 cyassl_log(ERROR_LOG , buffer);
162 #endif /* DEBUG_CYASSL */