Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Log.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Engine - Core module"
3 // For conditions of distribution and use, see copyright notice in Config.hpp
4 
5 #pragma once
6 
7 #ifndef NAZARA_LOG_HPP
8 #define NAZARA_LOG_HPP
9 
10 #include <Nazara/Prerequesites.hpp>
11 #include <Nazara/Core/Signal.hpp>
12 #include <Nazara/Core/String.hpp>
13 
14 #if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_LOG
15  #include <Nazara/Core/ThreadSafety.hpp>
16 #else
17  #include <Nazara/Core/ThreadSafetyOff.hpp>
18 #endif
19 
20 #ifdef NAZARA_DEBUG
21  #define NazaraDebug(txt) NazaraNotice(txt)
22 #else
23  #define NazaraDebug(txt)
24 #endif
25 
26 #define NazaraNotice(txt) Nz::Log::Write(txt)
27 
28 namespace Nz
29 {
30  class AbstractLogger;
31 
32  class NAZARA_CORE_API Log
33  {
34  friend class Core;
35 
36  public:
37  static void Enable(bool enable);
38 
39  static AbstractLogger* GetLogger();
40 
41  static bool IsEnabled();
42 
43  static void SetLogger(AbstractLogger* logger);
44 
45  static void Write(const String& string);
46  static void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr);
47 
48  NazaraStaticSignal(OnLogWrite, const String& /*string*/);
49  NazaraStaticSignal(OnLogWriteError, ErrorType /*type*/, const String& /*error*/, unsigned int /*line*/, const char* /*file*/, const char* /*function*/);
50 
51  private:
52  static bool Initialize();
53  static void Uninitialize();
54 
55  static AbstractLogger* s_logger;
56  static bool s_enabled;
57  };
58 }
59 
60 #endif // NAZARA_LOGGER_HPP
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Core class that represents a string.
Definition: String.hpp:22
Core class that represents a logger.
Definition: Log.hpp:32
Core class that represents the module initializer of Core.
Definition: Core.hpp:14
Core class that represents the behaviour of the log classes.
Definition: AbstractLogger.hpp:15