3 * Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
26 /* submitted by eof */
28 #include <cyassl/ctaocrypt/settings.h>
29 #include <cyassl/ctaocrypt/logging.h>
30 #include <cyassl/ctaocrypt/error.h>
36 CYASSL_API int CyaSSL_Debugging_ON(void);
37 CYASSL_API void CyaSSL_Debugging_OFF(void);
45 /* Set these to default values initially. */
46 static CyaSSL_Logging_cb log_function = 0;
47 static int loggingEnabled = 0;
49 #endif /* DEBUG_CYASSL */
52 int CyaSSL_SetLoggingCb(CyaSSL_Logging_cb f)
65 return NOT_COMPILED_IN;
70 int CyaSSL_Debugging_ON(void)
76 return NOT_COMPILED_IN;
81 void CyaSSL_Debugging_OFF(void)
91 #include <stdio.h> /* for default printf stuff */
94 int dc_log_printf(char*, ...);
97 static void cyassl_log(const int logLevel, const char *const logMessage)
100 log_function(logLevel, logMessage);
102 if (loggingEnabled) {
104 dc_log_printf("%s\n", logMessage);
105 #elif defined(MICRIUM)
106 #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
107 NetSecure_TraceOut((CPU_CHAR *)logMessage);
110 fprintf(stderr, "%s\n", logMessage);
117 void CYASSL_MSG(const char* msg)
120 cyassl_log(INFO_LOG , msg);
124 void CYASSL_ENTER(const char* msg)
126 if (loggingEnabled) {
128 sprintf(buffer, "CyaSSL Entering %s", msg);
129 cyassl_log(ENTER_LOG , buffer);
134 void CYASSL_LEAVE(const char* msg, int ret)
136 if (loggingEnabled) {
138 sprintf(buffer, "CyaSSL Leaving %s, return %d", msg, ret);
139 cyassl_log(LEAVE_LOG , buffer);
144 void CYASSL_ERROR(int error)
146 if (loggingEnabled) {
148 sprintf(buffer, "CyaSSL error occured, error = %d", error);
149 cyassl_log(ERROR_LOG , buffer);
153 #endif /* DEBUG_CYASSL */