Azure IoT common library

Fork of azure_c_shared_utility by Azure IoT

Committer:
AzureIoTClient
Date:
Fri Sep 09 13:38:26 2016 -0700
Revision:
11:77df6d7e65ae
Parent:
8:3db46d1e5471
Child:
18:6d8a413a4d9a
1.0.10

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Azure.IoT Build 6:c55b013dfc2a 1 // Copyright (c) Microsoft. All rights reserved.
Azure.IoT Build 6:c55b013dfc2a 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
Azure.IoT Build 6:c55b013dfc2a 3
Azure.IoT Build 6:c55b013dfc2a 4 #include <stdlib.h>
Azure.IoT Build 6:c55b013dfc2a 5 #ifdef _CRTDBG_MAP_ALLOC
Azure.IoT Build 6:c55b013dfc2a 6 #include <crtdbg.h>
Azure.IoT Build 6:c55b013dfc2a 7 #endif
Azure.IoT Build 6:c55b013dfc2a 8 #include <stdarg.h>
Azure.IoT Build 6:c55b013dfc2a 9 #include <stdio.h>
Azure.IoT Build 6:c55b013dfc2a 10 #include "azure_c_shared_utility/xlogging.h"
Azure.IoT Build 6:c55b013dfc2a 11
AzureIoTClient 8:3db46d1e5471 12 void consolelogger_log(LOG_CATEGORY log_category, const char* file, const char* func, const int line, unsigned int options, const char* format, ...)
Azure.IoT Build 6:c55b013dfc2a 13 {
AzureIoTClient 8:3db46d1e5471 14 va_list args;
AzureIoTClient 8:3db46d1e5471 15 va_start(args, format);
AzureIoTClient 7:1af47e3a19b6 16
AzureIoTClient 7:1af47e3a19b6 17 time_t t = time(NULL);
AzureIoTClient 7:1af47e3a19b6 18
AzureIoTClient 7:1af47e3a19b6 19 switch (log_category)
AzureIoTClient 7:1af47e3a19b6 20 {
AzureIoTClient 7:1af47e3a19b6 21 case LOG_INFO:
AzureIoTClient 7:1af47e3a19b6 22 (void)printf("Info: ");
AzureIoTClient 7:1af47e3a19b6 23 break;
AzureIoTClient 7:1af47e3a19b6 24 case LOG_ERROR:
AzureIoTClient 8:3db46d1e5471 25 (void)printf("Error: Time:%.24s File:%s Func:%s Line:%d ", ctime(&t), file, func, line);
AzureIoTClient 7:1af47e3a19b6 26 break;
AzureIoTClient 7:1af47e3a19b6 27 default:
AzureIoTClient 7:1af47e3a19b6 28 break;
AzureIoTClient 7:1af47e3a19b6 29 }
AzureIoTClient 7:1af47e3a19b6 30
Azure.IoT Build 6:c55b013dfc2a 31 (void)vprintf(format, args);
Azure.IoT Build 6:c55b013dfc2a 32 va_end(args);
Azure.IoT Build 6:c55b013dfc2a 33
Azure.IoT Build 6:c55b013dfc2a 34 (void)log_category;
Azure.IoT Build 6:c55b013dfc2a 35 if (options & LOG_LINE)
Azure.IoT Build 6:c55b013dfc2a 36 {
Azure.IoT Build 6:c55b013dfc2a 37 (void)printf("\r\n");
Azure.IoT Build 6:c55b013dfc2a 38 }
Azure.IoT Build 6:c55b013dfc2a 39 }