OSVR-Core
Log.h
Go to the documentation of this file.
1 
13 // Copyright 2016 Sensics, Inc.
14 //
15 // Licensed under the Apache License, Version 2.0 (the "License");
16 // you may not use this file except in compliance with the License.
17 // You may obtain a copy of the License at
18 //
19 // http://www.apache.org/licenses/LICENSE-2.0
20 //
21 // Unless required by applicable law or agreed to in writing, software
22 // distributed under the License is distributed on an "AS IS" BASIS,
23 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 // See the License for the specific language governing permissions and
25 // limitations under the License.
26 
27 #ifndef INCLUDED_Log_h_GUID_B6053E2B_593D_4ECA_8C3B_2C55D0FE6A49
28 #define INCLUDED_Log_h_GUID_B6053E2B_593D_4ECA_8C3B_2C55D0FE6A49
29 
30 // Internal Includes
31 #include <osvr/Util/Export.h>
32 #include <osvr/Util/SharedPtr.h>
33 #include <osvr/Util/UniquePtr.h>
34 
35 // Library/third-party includes
36 // - none
37 
38 // Standard includes
39 #include <string>
40 
43 #undef OSVR_USE_UNIQUEPTR_FOR_LOGGER
44 
45 namespace osvr {
46 namespace util {
47  namespace log {
48  class Logger;
49 #ifdef OSVR_USE_UNIQUEPTR_FOR_LOGGER
50  typedef unique_ptr<Logger> LoggerPtr;
51  typedef shared_ptr<Logger> LoggerSharedPtr;
52 #else
53  typedef shared_ptr<Logger> LoggerPtr;
54 #endif
55 
64  OSVR_UTIL_EXPORT bool
65  tryInitializingLoggingWithBaseName(std::string const &baseName);
66 
71  OSVR_UTIL_EXPORT LoggerPtr make_logger(const std::string &logger_name);
72 
78  OSVR_UTIL_EXPORT void drop(const std::string &logger_name);
79 
84  OSVR_UTIL_EXPORT void dropAll();
85 
88  OSVR_UTIL_EXPORT void flush();
89 
90  OSVR_UTIL_EXPORT std::string getLoggingDirectory(bool make_dir = false);
91 
92  } // end namespace log
93 } // end namespace util
94 } // end namespace osvr
95 
96 #endif // INCLUDED_Log_h_GUID_B6053E2B_593D_4ECA_8C3B_2C55D0FE6A49
Definition: RunLoopManager.h:42
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
OSVR_UTIL_EXPORT void dropAll()
Removes all the registered loggers from the registry.
Definition: Log.cpp:96
OSVR_UTIL_EXPORT void flush()
For implementations with a centralized logger registry, flush all logger sinks.
Definition: Log.cpp:100
Header to bring unique_ptr into the osvr namespace.
Header to bring shared_ptr into the osvr namespace.
OSVR_UTIL_EXPORT LoggerPtr make_logger(const std::string &logger_name)
Make (or get from the registry) a logger by name.
Definition: Log.cpp:81
OSVR_UTIL_EXPORT bool tryInitializingLoggingWithBaseName(std::string const &baseName)
Attempt to initialize the logging system with the indicated base filename (will be stripped of all ch...
Definition: Log.cpp:104
OSVR_UTIL_EXPORT void drop(const std::string &logger_name)
Drops a logger from the registry.
Definition: Log.cpp:92