1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef COMMON_UTILS_SCOPELOGGER_H
22 #define COMMON_UTILS_SCOPELOGGER_H
39 ScopeLogger(LogLevel level, const char* tag, const char* scopeName) :
42 m_scopeName{ scopeName }
44 static constexpr char DEFAULT_ENTER_STR[]{ "IN" };
46 OIC_LOG_V(m_level, m_tag, "%s %s", m_scopeName, DEFAULT_ENTER_STR);
51 static constexpr char DEFAULT_EXIT_STR[]{ "OUT" };
53 if (std::uncaught_exception())
55 OIC_LOG_V(m_level, m_tag, "%s %s by stack unwinding (uncaught exception)",
56 m_scopeName, DEFAULT_EXIT_STR);
60 OIC_LOG_V(m_level, m_tag, "%s %s", m_scopeName, DEFAULT_EXIT_STR);
64 ScopeLogger(const ScopeLogger&) = delete;
65 ScopeLogger(ScopeLogger&&) = delete;
67 ScopeLogger& operator=(const ScopeLogger&) = delete;
68 ScopeLogger& operator=(ScopeLogger&&) = delete;
71 const LogLevel m_level;
73 const char* m_scopeName;
80 #define SCOPE_LOG(level, tag, scopeName) \
81 Logging::ScopeLogger rcsScopeLogger__((level), (tag), (scopeName))
83 #define SCOPE_LOG_F(level, tag) SCOPE_LOG((level), (tag), __func__)
86 #define SCOPE_LOG_F(level, tag)
87 #define SCOPE_LOG(level, tag, scopeName)
91 #endif // COMMON_UTILS_SCOPELOGGER_H