Azure IoT common library

Dependents:   STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more

Committer:
AzureIoTClient
Date:
Fri Apr 21 14:51:10 2017 -0700
Revision:
25:8507bf644fdf
Parent:
19:2e0811512ceb
Child:
27:8656a313842b
1.1.13

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 <stdarg.h>
Azure.IoT Build 6:c55b013dfc2a 5 #include <stdio.h>
AzureIoTClient 19:2e0811512ceb 6 #include <time.h>
Azure.IoT Build 6:c55b013dfc2a 7 #include "azure_c_shared_utility/xlogging.h"
AzureIoTClient 25:8507bf644fdf 8 #include "azure_c_shared_utility/consolelogger.h"
Azure.IoT Build 6:c55b013dfc2a 9
AzureIoTClient 25:8507bf644fdf 10 #if defined(__GNUC__)
AzureIoTClient 25:8507bf644fdf 11 __attribute__ ((format (printf, 6, 7)))
AzureIoTClient 25:8507bf644fdf 12 #endif
AzureIoTClient 8:3db46d1e5471 13 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 14 {
AzureIoTClient 8:3db46d1e5471 15 va_list args;
AzureIoTClient 8:3db46d1e5471 16 va_start(args, format);
AzureIoTClient 7:1af47e3a19b6 17
AzureIoTClient 7:1af47e3a19b6 18 time_t t = time(NULL);
AzureIoTClient 7:1af47e3a19b6 19
AzureIoTClient 7:1af47e3a19b6 20 switch (log_category)
AzureIoTClient 7:1af47e3a19b6 21 {
AzureIoTClient 18:6d8a413a4d9a 22 case AZ_LOG_INFO:
AzureIoTClient 7:1af47e3a19b6 23 (void)printf("Info: ");
AzureIoTClient 7:1af47e3a19b6 24 break;
AzureIoTClient 18:6d8a413a4d9a 25 case AZ_LOG_ERROR:
AzureIoTClient 8:3db46d1e5471 26 (void)printf("Error: Time:%.24s File:%s Func:%s Line:%d ", ctime(&t), file, func, line);
AzureIoTClient 7:1af47e3a19b6 27 break;
AzureIoTClient 7:1af47e3a19b6 28 default:
AzureIoTClient 7:1af47e3a19b6 29 break;
AzureIoTClient 7:1af47e3a19b6 30 }
AzureIoTClient 7:1af47e3a19b6 31
Azure.IoT Build 6:c55b013dfc2a 32 (void)vprintf(format, args);
Azure.IoT Build 6:c55b013dfc2a 33 va_end(args);
Azure.IoT Build 6:c55b013dfc2a 34
Azure.IoT Build 6:c55b013dfc2a 35 (void)log_category;
Azure.IoT Build 6:c55b013dfc2a 36 if (options & LOG_LINE)
Azure.IoT Build 6:c55b013dfc2a 37 {
Azure.IoT Build 6:c55b013dfc2a 38 (void)printf("\r\n");
Azure.IoT Build 6:c55b013dfc2a 39 }
Azure.IoT Build 6:c55b013dfc2a 40 }