1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
22 * @file simulator_logger.h
24 * @brief This file provides the interface for logging messages to different targets (console/file).
27 #ifndef SIMULATOR_LOGGER_H_
28 #define SIMULATOR_LOGGER_H_
44 static const char *getString(Level level)
48 case Level::INFO: return "INFO";
49 case Level::DEBUG: return "DEBUG";
50 case Level::WARNING: return "WARNING";
51 case Level::ERROR: return "ERROR";
52 default: return "UNKNOWN";
56 virtual void write(std::string, Level, std::string) = 0;
62 bool setDefaultConsoleTarget();
63 bool setDefaultFileTarget(const std::string &path);
64 void setCustomTarget(const std::shared_ptr<ILogger> &target);
65 void write(ILogger::Level level, std::ostringstream &str);
68 std::shared_ptr<ILogger> m_target;
71 auto simLogger() -> Logger &;
74 #define SIM_LOG(LEVEL, MSG) { \
75 simLogger().write(LEVEL, static_cast<std::ostringstream&>(std::ostringstream()<<MSG)); \