ARM Shanghai IoT Team (Internal) / newMiniTLS-GPL

Fork of MiniTLS-GPL by Donatien Garnier

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers debug.c Source File

debug.c

00001 /*
00002 MiniTLS - A super trimmed down TLS/SSL Library for embedded devices
00003 Author: Donatien Garnier
00004 Copyright (C) 2013-2014 AppNearMe Ltd
00005 
00006 This program is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU General Public License
00008 as published by the Free Software Foundation; either version 2
00009 of the License, or (at your option) any later version.
00010 
00011 This program is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with this program; if not, write to the Free Software
00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019 *//*
00020   debug.c
00021  * Copyright (c) AppNearMe Ltd 2013
00022  * Author: Donatien Garnier
00023  */
00024 
00025 #include "fwk.h"
00026 
00027 #if !DEBUG_DISABLED
00028 
00029 #ifdef __cplusplus
00030 extern "C"
00031 {
00032 #endif
00033 
00034 #include "debug.h"
00035 
00036 #include "stdio.h"
00037 #include "stdarg.h"
00038 
00039 void debug(int level, const char* module, int line, const char* fmt, ...)
00040 {
00041   va_list argp;
00042 
00043   //TODO add a mutex system at some point here
00044   switch(level)
00045   {
00046   default:
00047   case 1:
00048     printf("[ERROR]");
00049     break;
00050   case 2:
00051     printf("[WARN]");
00052     break;
00053   case 3:
00054     printf("[DBG]");
00055     break;
00056   case 4:
00057     printf("[VERB]");
00058     break;
00059   }
00060 
00061   printf(" Module %s - Line %d: ", module, line);
00062 
00063   va_start(argp, fmt);
00064   vprintf(fmt, argp);
00065   va_end(argp);
00066 
00067   printf("\r\n");
00068 }
00069 
00070 void debugx_enter(void)
00071 {
00072 
00073 }
00074 
00075 void debugx(const char* fmt, ...)
00076 {
00077   va_list argp;
00078 
00079   va_start(argp, fmt);
00080   vprintf(fmt, argp);
00081   va_end(argp);
00082 }
00083 
00084 void debugx_leave(void)
00085 {
00086   printf("\r\n");
00087 }
00088 
00089 void assert_failed(const char* module, int line, const char* condition)
00090 {
00091   printf("[ASSERT FAILED] Module %s - Line %d: %s\r\n", module, line, condition);
00092 }
00093 
00094 #ifdef __cplusplus
00095 }
00096 #endif
00097 
00098 #endif
00099