2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2009 Dolphin Emulator Project
|
2015-05-18 01:08:10 +02:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 23:09:55 -04:00
|
|
|
// Refer to the license.txt file included.
|
2009-03-18 17:17:58 +00:00
|
|
|
|
2014-02-10 13:54:46 -05:00
|
|
|
#pragma once
|
2009-03-18 17:17:58 +00:00
|
|
|
|
2015-10-04 00:34:36 +13:00
|
|
|
#include <array>
|
2014-02-20 04:11:52 +01:00
|
|
|
#include <cstdarg>
|
2014-06-05 18:24:10 -04:00
|
|
|
#include <string>
|
2009-03-18 17:17:58 +00:00
|
|
|
|
2015-09-26 17:13:07 -04:00
|
|
|
#include "Common/Logging/Log.h"
|
2016-06-24 10:43:46 +02:00
|
|
|
#include "Common/NonCopyable.h"
|
2014-02-17 05:18:15 -05:00
|
|
|
|
2011-04-01 07:43:02 +00:00
|
|
|
// pure virtual interface
|
|
|
|
class LogListener
|
|
|
|
{
|
2009-03-18 17:17:58 +00:00
|
|
|
public:
|
2016-06-24 10:43:46 +02:00
|
|
|
virtual ~LogListener() {}
|
|
|
|
virtual void Log(LogTypes::LOG_LEVELS, const char* msg) = 0;
|
2011-04-01 07:43:02 +00:00
|
|
|
|
2016-06-24 10:43:46 +02:00
|
|
|
enum LISTENER
|
|
|
|
{
|
|
|
|
FILE_LISTENER = 0,
|
|
|
|
CONSOLE_LISTENER,
|
|
|
|
LOG_WINDOW_LISTENER,
|
2015-10-04 00:34:36 +13:00
|
|
|
|
2016-06-24 10:43:46 +02:00
|
|
|
NUMBER_OF_LISTENERS // Must be last
|
|
|
|
};
|
2009-03-18 17:17:58 +00:00
|
|
|
};
|
|
|
|
|
2017-07-07 15:00:25 -07:00
|
|
|
class LogContainer;
|
2014-02-23 07:33:03 +01:00
|
|
|
|
2010-11-15 05:29:10 +00:00
|
|
|
class LogManager : NonCopyable
|
2009-03-18 17:17:58 +00:00
|
|
|
{
|
2016-06-24 10:43:46 +02:00
|
|
|
public:
|
2017-07-07 15:00:25 -07:00
|
|
|
static LogManager* GetInstance();
|
|
|
|
static void Init();
|
|
|
|
static void Shutdown();
|
|
|
|
|
2016-06-24 10:43:46 +02:00
|
|
|
void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
|
|
|
|
const char* fmt, va_list args);
|
2017-04-23 23:55:37 -07:00
|
|
|
void LogWithFullPath(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file,
|
|
|
|
int line, const char* fmt, va_list args);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2017-07-07 15:00:25 -07:00
|
|
|
void SetLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2017-07-07 15:00:25 -07:00
|
|
|
void SetEnable(LogTypes::LOG_TYPE type, bool enable);
|
|
|
|
bool IsEnabled(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level = LogTypes::LNOTICE) const;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2017-07-07 15:00:25 -07:00
|
|
|
std::string GetShortName(LogTypes::LOG_TYPE type) const;
|
|
|
|
std::string GetFullName(LogTypes::LOG_TYPE type) const;
|
|
|
|
void RegisterListener(LogListener::LISTENER id, LogListener* listener);
|
|
|
|
void AddListener(LogTypes::LOG_TYPE type, LogListener::LISTENER id);
|
|
|
|
void RemoveListener(LogTypes::LOG_TYPE type, LogListener::LISTENER id);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2017-07-07 15:00:25 -07:00
|
|
|
private:
|
|
|
|
LogManager();
|
|
|
|
~LogManager();
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2017-07-07 15:00:25 -07:00
|
|
|
LogContainer* m_log[LogTypes::NUMBER_OF_LOGS];
|
|
|
|
std::array<LogListener*, LogListener::NUMBER_OF_LISTENERS> m_listeners{};
|
|
|
|
size_t m_path_cutoff_point = 0;
|
2009-03-18 17:17:58 +00:00
|
|
|
};
|