Mark Radbourne / Mbed 2 deprecated iothub_client_sample_amqp

Dependencies:   EthernetInterface NTPClient iothub_amqp_transport iothub_client mbed-rtos mbed

Fork of iothub_client_sample_amqp by Azure IoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers consolelogger.c Source File

consolelogger.c

00001 // Copyright (c) Microsoft. All rights reserved.
00002 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
00003 
00004 #include <stdlib.h>
00005 #ifdef _CRTDBG_MAP_ALLOC
00006 #include <crtdbg.h>
00007 #endif
00008 #include <stdarg.h>
00009 #include <stdio.h>
00010 #include "azure_c_shared_utility/xlogging.h"
00011 
00012 void consolelogger_log(LOG_CATEGORY log_category, const char* file, const char* func, const int line, unsigned int options, const char* format, ...)
00013 {
00014     va_list args;
00015     va_start(args, format);
00016 
00017     time_t t = time(NULL); 
00018     
00019     switch (log_category)
00020     {
00021     case LOG_INFO:
00022         (void)printf("Info: ");
00023         break;
00024     case LOG_ERROR:
00025         (void)printf("Error: Time:%.24s File:%s Func:%s Line:%d ", ctime(&t), file, func, line);
00026         break;
00027     default:
00028         break;
00029     }
00030 
00031     (void)vprintf(format, args);
00032     va_end(args);
00033 
00034     (void)log_category;
00035     if (options & LOG_LINE)
00036     {
00037         (void)printf("\r\n");
00038     }
00039 }