1 // Copyright 2019 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
11 #define LOG_TAG "CHROMIUM"
13 #include <dlog/dlog.h>
21 #define __DLOG_UTIL_FMT__ "%s:%s(%d) > "
22 #define __DLOG_UTIL_FILE__ \
23 (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 \
26 #define TIZEN_DLOG_PRINT(priority, fmt, ...) \
27 dlog_print(priority, LOG_TAG, __DLOG_UTIL_FMT__ fmt, __DLOG_UTIL_FILE__, \
28 __FUNCTION__, __LINE__, ##__VA_ARGS__)
30 class TizenDlogWrapper {
32 TizenDlogWrapper(log_priority priority,
36 : priority_(priority), file_(file), line_(line), func_(func) {}
38 dlog_print(priority_, LOG_TAG, __DLOG_UTIL_FMT__ "%s", file_, func_, line_,
39 stream_.str().data());
41 if (!fstream_.is_open())
45 if (!clock_gettime(CLOCK_MONOTONIC, &ts) &&
46 localtime_r(&ts.tv_sec, &local)) {
48 int ms = ts.tv_nsec / 1000000;
49 strftime(buffer, sizeof(buffer), "%m-%d %H:%M:%S", &local);
51 snprintf(buffer, sizeof(buffer), ":%03d ", ms);
54 fstream_ << "[" << getpid() << "] " << file_ << ":" << func_ << "(" << line_
55 << ") > " << stream_.str() << std::endl;
58 std::ostream& stream() { return stream_; }
61 static std::ofstream fstream_;
65 log_priority priority_;
69 std::ostringstream stream_;
72 #define TIZEN_DLOG_STREAM(priority) \
73 TizenDlogWrapper(priority, __DLOG_UTIL_FILE__, __LINE__, __FUNCTION__) \
76 // redefine LOG macro function defined in dlog-internal.h
80 #define LOG(priority) TIZEN_DLOG_STREAM(DLOG_##priority)