Merge "Partial Implementation of US1574:"
[platform/upstream/iotivity.git] / csdk / controller / core / include / core / SimpleLogger.cpp
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21
22 /*
23  * SimpleLogger.cpp
24  *
25  *  Created on: Mar 27, 2014
26  *      Author: dkhudson
27  */
28 #include "SimpleLogger.h"
29
30 #ifdef __ANDROID__
31   #include <android/log.h>
32 #endif
33
34 namespace Intel {
35 namespace CCFL {
36
37 void LOG(const char * format, ...) {
38 #ifdef __ANDROID__
39   va_list args;
40   va_start (args, format);
41   __android_log_vprint(ANDROID_LOG_INFO, "CCF-Lite-ANDROID", format, args);
42   va_end (args);
43 #elif defined __linux__
44   printf("INFO: CCF-Lite-LINUX: ");
45   va_list args;
46   va_start (args, format);
47   vprintf(format, args);
48   va_end (args);
49   printf("\n");
50 #endif
51 }
52
53 void logDebug(const char * tag, const char * format, ...) {
54 #ifdef __ANDROID__
55     va_list args;
56     va_start (args, format);
57     __android_log_vprint(ANDROID_LOG_DEBUG, tag, format, args);
58     va_end (args);
59 #elif defined __linux__
60     printf("DEBUG: %s: ", tag);
61     va_list args;
62     va_start (args, format);
63     vprintf(format, args);
64     va_end (args);
65     printf("\n");
66 #endif
67 }
68 void logInfo(const char * tag, const char * format, ...) {
69 #ifdef __ANDROID__
70     va_list args;
71     va_start (args, format);
72     __android_log_vprint(ANDROID_LOG_INFO, tag, format, args);
73     va_end (args);
74 #elif defined __linux__
75     printf("INFO: %s: ", tag);
76     va_list args;
77     va_start (args, format);
78     vprintf(format, args);
79     va_end (args);
80     printf("\n");
81 #endif
82 }
83
84 void logWarn(const char * tag, const char * format, ...) {
85 #ifdef __ANDROID__
86     va_list args;
87     va_start (args, format);
88     __android_log_vprint(ANDROID_LOG_WARN, tag, format, args);
89     va_end (args);
90 #elif defined __linux__
91     printf("WARN: %s: ", tag);
92     va_list args;
93     va_start (args, format);
94     vprintf(format, args);
95     va_end (args);
96     printf("\n");
97 #endif
98 }
99
100 void logError(const char * tag, const char * format, ...) {
101 #ifdef __ANDROID__
102     va_list args;
103     va_start (args, format);
104     __android_log_vprint(ANDROID_LOG_ERROR, tag, format, args);
105     va_end (args);
106 #elif defined __linux__
107     printf("ERROR: %s: ", tag);
108     va_list args;
109     va_start (args, format);
110     vprintf(format, args);
111     va_end (args);
112     printf("\n");
113 #endif
114 }
115
116 void logFatal(const char * tag, const char * format, ...) {
117 #ifdef __ANDROID__
118     va_list args;
119     va_start (args, format);
120     __android_log_vprint(ANDROID_LOG_FATAL, tag, format, args);
121     va_end (args);
122 #elif defined __linux__
123     printf("FATAL: %s: ", tag);
124     va_list args;
125     va_start (args, format);
126     vprintf(format, args);
127     va_end (args);
128     printf("\n");
129 #endif
130 }
131
132 }
133 }