Merge branch 'NDK' of https://github.com/DigitalPulseSoftware/NazaraEngine into NDK
Former-commit-id: ddfe1d92246d6717e4e4ec2e982eddfa1b74ed50
This commit is contained in:
9
include/Nazara/Core/AbstractLogger.docx
Normal file
9
include/Nazara/Core/AbstractLogger.docx
Normal file
@@ -0,0 +1,9 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
/*!
|
||||
* \class Nz::AbstractLogger
|
||||
* \brief Logger interface
|
||||
*/
|
||||
|
||||
31
include/Nazara/Core/AbstractLogger.hpp
Normal file
31
include/Nazara/Core/AbstractLogger.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ABSTRACTLOGGER_HPP
|
||||
#define NAZARA_ABSTRACTLOGGER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API AbstractLogger
|
||||
{
|
||||
public:
|
||||
AbstractLogger() = default;
|
||||
virtual ~AbstractLogger();
|
||||
|
||||
virtual void EnableStdReplication(bool enable) = 0;
|
||||
|
||||
virtual bool IsStdReplicationEnabled() = 0;
|
||||
|
||||
virtual void Write(const String& string) = 0;
|
||||
virtual void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ABSTRACTLOGGER_HPP
|
||||
46
include/Nazara/Core/FileLogger.hpp
Normal file
46
include/Nazara/Core/FileLogger.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_FILELOGGER_HPP
|
||||
#define NAZARA_FILELOGGER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/AbstractLogger.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/StdLogger.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API FileLogger : public AbstractLogger
|
||||
{
|
||||
public:
|
||||
FileLogger(const String& logPath = "NazaraLog.log");
|
||||
FileLogger(const FileLogger&) = default;
|
||||
FileLogger(FileLogger&&) = default;
|
||||
~FileLogger();
|
||||
|
||||
void EnableTimeLogging(bool enable);
|
||||
void EnableStdReplication(bool enable) override;
|
||||
|
||||
bool IsStdReplicationEnabled() override;
|
||||
bool IsTimeLoggingEnabled();
|
||||
|
||||
void Write(const String& string) override;
|
||||
void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override;
|
||||
|
||||
FileLogger& operator=(const FileLogger&) = default;
|
||||
FileLogger& operator=(FileLogger&&) = default;
|
||||
|
||||
private:
|
||||
File m_outputFile;
|
||||
StdLogger m_stdLogger;
|
||||
bool m_forceStdOutput;
|
||||
bool m_stdReplicationEnabled;
|
||||
bool m_timeLoggingEnabled;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_FILELOGGER_HPP
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <memory>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_LOG
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
@@ -23,48 +25,37 @@
|
||||
#define NazaraDebug(txt)
|
||||
#endif
|
||||
|
||||
#define NazaraLog Nz::Log::Instance()
|
||||
#define NazaraNotice(txt) NazaraLog->Write(txt)
|
||||
#define NazaraNotice(txt) Nz::Log::Write(txt)
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class File;
|
||||
class AbstractLogger;
|
||||
|
||||
class NAZARA_CORE_API Log
|
||||
{
|
||||
friend class Core;
|
||||
|
||||
public:
|
||||
void Enable(bool enable);
|
||||
void EnableAppend(bool enable);
|
||||
void EnableDateTime(bool enable);
|
||||
static void Enable(bool enable);
|
||||
|
||||
String GetFile() const;
|
||||
static AbstractLogger* GetLogger();
|
||||
|
||||
bool IsEnabled() const;
|
||||
static bool IsEnabled();
|
||||
|
||||
void SetFile(const String& filePath);
|
||||
static void SetLogger(AbstractLogger* logger);
|
||||
|
||||
void Write(const String& string);
|
||||
void WriteError(ErrorType type, const String& error);
|
||||
void WriteError(ErrorType type, const String& error, unsigned int line, const String& file, const String& func);
|
||||
static void Write(const String& string);
|
||||
static void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr);
|
||||
|
||||
static Log* Instance();
|
||||
NazaraStaticSignal(OnLogWrite, const String& /*string*/);
|
||||
NazaraStaticSignal(OnLogWriteError, ErrorType /*type*/, const String& /*error*/, unsigned int /*line*/, const char* /*file*/, const char* /*function*/);
|
||||
|
||||
private:
|
||||
Log();
|
||||
Log(const Log&) = delete;
|
||||
Log(Log&&) = delete;
|
||||
~Log();
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
Log& operator=(const Log&) = delete;
|
||||
Log& operator=(Log&&) = delete;
|
||||
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
String m_filePath;
|
||||
File* m_file;
|
||||
bool m_append;
|
||||
bool m_enabled;
|
||||
bool m_writeTime;
|
||||
static AbstractLogger* s_logger;
|
||||
static bool s_enabled;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,12 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#define NazaraSignal(SignalName, ...) using SignalName ## Type = Nz::Signal<__VA_ARGS__>; \
|
||||
mutable SignalName ## Type SignalName
|
||||
#define NazaraDetailSignal(Keyword, SignalName, ...) using SignalName ## Type = Nz::Signal<__VA_ARGS__>; \
|
||||
Keyword SignalName ## Type SignalName
|
||||
|
||||
#define NazaraSignal(SignalName, ...) NazaraDetailSignal(mutable, SignalName, __VA_ARGS__)
|
||||
#define NazaraStaticSignal(SignalName, ...) NazaraDetailSignal(static, SignalName, __VA_ARGS__)
|
||||
#define NazaraStaticSignalImpl(Class, SignalName) Class :: SignalName ## Type Class :: SignalName
|
||||
|
||||
#define NazaraSlotType(Class, SignalName) Class::SignalName ## Type::ConnectionGuard
|
||||
#define NazaraSlot(Class, SignalName, SlotName) NazaraSlotType(Class, SignalName) SlotName
|
||||
|
||||
35
include/Nazara/Core/StdLogger.hpp
Normal file
35
include/Nazara/Core/StdLogger.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_STDLOGGER_HPP
|
||||
#define NAZARA_STDLOGGER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/AbstractLogger.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API StdLogger : public AbstractLogger
|
||||
{
|
||||
public:
|
||||
StdLogger() = default;
|
||||
StdLogger(const StdLogger&) = default;
|
||||
StdLogger(StdLogger&&) = default;
|
||||
~StdLogger();
|
||||
|
||||
void EnableStdReplication(bool enable) override;
|
||||
|
||||
bool IsStdReplicationEnabled() override;
|
||||
|
||||
void Write(const String& string) override;
|
||||
void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override;
|
||||
|
||||
StdLogger& operator=(const StdLogger&) = default;
|
||||
StdLogger& operator=(StdLogger&&) = default;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_STDLOGGER_HPP
|
||||
Reference in New Issue
Block a user