2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef WRT_COMMON_LOGGER_H_
18 #define WRT_COMMON_LOGGER_H_
24 #define LOGGER_TAG "WRT"
26 #define _LOGGER_LOG(prio, fmt, args...) \
27 LOG_(LOG_ID_MAIN, prio, LOGGER_TAG, fmt, ##args)
29 #define _LOGGER_SLOG(prio, fmt, args...) \
30 SECURE_LOG_(LOG_ID_MAIN, prio, LOGGER_TAG, fmt, ##args)
32 #define LoggerD(fmt, args...) _LOGGER_LOG(DLOG_DEBUG, fmt, ##args)
33 #define LoggerI(fmt, args...) _LOGGER_LOG(DLOG_INFO, fmt, ##args)
34 #define LoggerW(fmt, args...) _LOGGER_LOG(DLOG_WARN, fmt, ##args)
35 #define LoggerE(fmt, args...) _LOGGER_LOG(DLOG_ERROR, fmt, ##args)
37 #define SLoggerD(fmt, args...) _LOGGER_SLOG(DLOG_DEBUG, fmt, ##args)
38 #define SLoggerI(fmt, args...) _LOGGER_SLOG(DLOG_INFO, fmt, ##args)
39 #define SLoggerW(fmt, args...) _LOGGER_SLOG(DLOG_WARN, fmt, ##args)
40 #define SLoggerE(fmt, args...) _LOGGER_SLOG(DLOG_ERROR, fmt, ##args)
45 class LogMessageVodify {
48 void operator&(const std::ostream&) const {}
53 LogMessage(int severity, const char* file, const char* func, const int line)
54 : severity_(severity), file_(file), func_(func), line_(line) {}
56 __dlog_print(LOG_ID_MAIN, severity_, LOGGER_TAG,
57 "%s: %s(%d) > %s", file_, func_, line_, stream_.str().c_str());
59 std::ostream& stream() { return stream_; }
65 std::ostringstream stream_;
73 (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
76 #define LOGGER(severity) \
77 wrt::utils::LogMessageVodify() & \
78 wrt::utils::LogMessage(DLOG_ ## severity, \
79 __MODULE__, __FUNCTION__, __LINE__).stream()
82 #endif // WRT_COMMON_LOGGER_H_