2 * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
4 * Contact: Suresh Kumar N (suresh.n@samsung.com)
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
27 #include <zblib_log.h>
29 #define BUFFER_SIZE 1024
31 void zblib_log(enum zblib_log_type type, enum zblib_log_priority priority, const char *tag, const char *fmt, ...)
34 char buf[BUFFER_SIZE];
35 int log_id = LOG_ID_RADIO;
38 case ZIGBEE_LOG_TYPE_SYSTEM: {
39 if (priority >= ZIGBEE_LOG_INFO) {
41 vsnprintf(buf, BUFFER_SIZE-1, fmt, ap);
43 __dlog_print(log_id, priority, tag, "%s", buf);
45 #ifdef TIZEN_DEBUG_ENABLE
47 vsnprintf(buf, BUFFER_SIZE-1, fmt, ap);
49 __dlog_print(log_id, priority, tag, "%s", buf);
55 case ZIGBEE_LOG_TYPE_TIME_CHECK: {
56 #ifdef TIZEN_DEBUG_ENABLE /* User Mode should not log performance data */
57 float a = 0.00, b = 0.00;
59 FILE *fp = fopen("/proc/uptime", "r");
61 Z_LOGE("fopen() failed");
64 if (fscanf(fp, "%f %f", &a, &b) != 1)
65 next = snprintf(buf, BUFFER_SIZE, "[UPTIME] [Not Set] ");
67 next = snprintf(buf, BUFFER_SIZE, "[UPTIME] %f ", a);
73 vsnprintf(buf + next, (BUFFER_SIZE-1) - next, fmt, ap);
75 __dlog_print(log_id, priority, tag, "%s", buf);