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