AGX Dynamics  2.35.0.1
Logger.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #define g_LogMgr agx::Logger::instance()
20 
21 #define LOGGER() agx::Logger::instance()->getNotify()
22 #define LOGGER_ERROR() LOGGER() << LOGGER().NOTIFY_ERROR()
23 #define LOGGER_WARNING() LOGGER() << LOGGER().NOTIFY_WARNING()
24 #define LOGGER_INFO() LOGGER() << LOGGER().NOTIFY_INFO()
25 #define LOGGER_DEBUG() LOGGER() << LOGGER().NOTIFY_DEBUG()
26 #define LOGGER_END() LOGGER().NOTIFY_END()
27 #define LOGGER_ENDL() std::endl << LOGGER().NOTIFY_END()
28 
29 #define LOGGER_ERROR_IF_nullptr(Y) NOTIFY_ERROR_IF_nullptr(LOGGER(), Y)
30 #define LOGGER_ERROR_IF_TRUE(Y) NOTIFY_ERROR_IF_TRUE(LOGGER(), Y)
31 #define LOGGER_ERROR_IF_FALSE(Y) NOTIFY_ERROR_IF_FALSE(LOGGER(), Y)
32 
33 #define LOGGER_WARNING_IF_nullptr(Y) NOTIFY_ERROR_IF_nullptr(LOGGER(), Y)
34 #define LOGGER_ERROR_IF_TRUE(Y) NOTIFY_ERROR_IF_TRUE(LOGGER(), Y)
35 #define LOGGER_ERROR_IF_FALSE(Y) NOTIFY_ERROR_IF_FALSE(LOGGER(), Y)
36 #define LOGGER_STATE(X) LOGGER().NOTIFY_STATE(X)
37 
38 #include <agx/agx.h>
39 #include <agx/Notify.h>
40 #include <agx/Singleton.h>
41 namespace agx
42 {
43 
52  {
53  public:
54 
55  Logger();
57  static Logger *instance( void );
58 
60  SINGLETON_CLASSNAME_METHOD();
61 
70  bool openLogfile( const agx::String& path, bool overwrite, bool closeAndOpen );
71 
76 
81 
82  protected:
83  void shutdown() override;
84 
85  private:
86  virtual ~Logger();
87  static Logger *s_instance;
88 
89  };
90 
92 
93 } // namespace agx
94 
95 
96 // Only used by lua bindings
97 namespace agx
98 {
99  void AGXCORE_EXPORT logDebug(std::string str);
100  void AGXCORE_EXPORT logInfo(std::string str);
101  void AGXCORE_EXPORT logWarning(std::string str);
102  void AGXCORE_EXPORT logError(std::string str);
103 }
104 
105 
#define AGXCORE_EXPORT
Logger is a class for writing information, debug info, warnings but also throwing exceptions in a str...
Definition: Logger.h:52
void shutdown() override
Implement this method to cleanup your Singleton class.
bool openLogfile(const agx::String &path, bool overwrite, bool closeAndOpen)
Open a new log file.
void setLogNotifyLevel(Notify::NotifyLevel l)
Set the lowest level of messages that will be written to the logger system.
static Logger * instance(void)
Return the singleton object.
ADD_NOTIFY_FUNCTIONALITY_TO_CLASS()
agx::String getLogFilename() const
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Definition: Singleton.h:31
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
void AGXCORE_EXPORT logDebug(std::string str)
void AGXCORE_EXPORT logWarning(std::string str)
ref_ptr< Logger > LoggerRef
Definition: Logger.h:91
void AGXCORE_EXPORT logInfo(std::string str)
void AGXCORE_EXPORT logError(std::string str)