Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
logger-scope.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Contact: Lukasz Kostyra <l.kostyra@samsung.com>
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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
17  */
18 
25 #ifndef LOGGER_LOGGER_SCOPE_HPP
26 #define LOGGER_LOGGER_SCOPE_HPP
27 
28 #include <string>
29 #include <sstream>
30 
31 namespace logger {
32 
34 {
35 public:
36  operator std::string() const;
37 
38  template <typename T>
40  {
41  this->mSStream << b;
42  return *this;
43  }
44 
45 private:
46  std::ostringstream mSStream;
47 };
48 
54 {
55 public:
56  LoggerScope(const std::string& file,
57  const unsigned int line,
58  const std::string& func,
59  const std::string& message,
60  const std::string& rootDir);
61  ~LoggerScope();
62 
63 private:
64  const std::string mFile;
65  const unsigned int mLine;
66  const std::string mFunc;
67  const std::string mMessage;
68  const std::string mRootDir;
69 };
70 
71 } // namespace logger
72 
77 #if !defined(NDEBUG)
78 #define LOGS(MSG) logger::LoggerScope logScopeObj(__FILE__, __LINE__, __func__, \
79  logger::SStreamWrapper() << MSG, \
80  PROJECT_SOURCE_DIR)
81 #else
82 #define LOGS(MSG) do {} while (0)
83 #endif
84 
85 #endif // LOGGER_LOGGER_SCOPE_HPP
const std::string mFunc
Definition: logger-scope.hpp:66
Class specifically for scope debug logging.
Definition: logger-scope.hpp:53
const unsigned int mLine
Definition: logger-scope.hpp:65
LoggerScope(const std::string &file, const unsigned int line, const std::string &func, const std::string &message, const std::string &rootDir)
Definition: logger-scope.cpp:35
const std::string mMessage
Definition: logger-scope.hpp:67
std::ostringstream mSStream
Definition: logger-scope.hpp:46
const std::string mRootDir
Definition: logger-scope.hpp:68
const std::string mFile
Definition: logger-scope.hpp:64
SStreamWrapper & operator<<(const T &b)
Definition: logger-scope.hpp:39
~LoggerScope()
Definition: logger-scope.cpp:52
Definition: logger-scope.hpp:33