修改部分ScreenManager
This commit is contained in:
parent
2ea026f7be
commit
5c00047718
@ -4,7 +4,7 @@
|
||||
#include <iostream>
|
||||
#include <Windows.h>
|
||||
#include <string>
|
||||
#include <spdlog.h>
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
19
WinDevice/Utils/Log.cpp
Normal file
19
WinDevice/Utils/Log.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "Log.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
|
||||
void Log::Init(LogLevel level, std::string fileName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Log::Info(std::string format, std::string args...)
|
||||
{
|
||||
spdlog::info(format, args);
|
||||
}
|
||||
|
||||
void Log::WInfo(std::wstring format, std::wstring args...)
|
||||
{
|
||||
std::string s_format(format.begin(), format.end());
|
||||
|
||||
}
|
17
WinDevice/Utils/Log.h
Normal file
17
WinDevice/Utils/Log.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
enum LogLevel : int
|
||||
{
|
||||
Debug = spdlog::level::debug,
|
||||
Info = spdlog::level::info,
|
||||
};
|
||||
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
static void Init(LogLevel level, std::string fileName);
|
||||
|
||||
static void Info(std::string format, std::string args...);
|
||||
static void WInfo(std::wstring format, std::wstring args...);
|
||||
};
|
24
WinDevice/Utils/StringUtil.h
Normal file
24
WinDevice/Utils/StringUtil.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef STRING_UTIL_H
|
||||
#define STRING_UTIL_H
|
||||
|
||||
#include <string>
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
|
||||
template<typename To, typename From>
|
||||
To Convert(const From& input) {
|
||||
std::wstring_convert<std::codecvt_utf8<typename From::value_type>, typename From::value_type> converter;
|
||||
return converter.to_bytes(input);
|
||||
}
|
||||
|
||||
std::string Wstring2String(const std::wstring& input) {
|
||||
return Convert<std::string>(input);
|
||||
}
|
||||
|
||||
std::string Wchar2String(const WCHAR* input) {
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
|
||||
return converter.to_bytes(input);
|
||||
}
|
||||
|
||||
|
||||
#endif // STRING_CONVERSION_H
|
@ -1,5 +1,5 @@
|
||||
#include "TimeUtil.h"
|
||||
#include <spdlog.h>
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
|
||||
template <typename Func>
|
||||
|
@ -1,15 +1,97 @@
|
||||
#include "ScreenManager.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "spdlog/sinks/basic_file_sink.h"
|
||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||
#include "Utils/StringUtil.h"
|
||||
|
||||
|
||||
void SceenManager::UpdateDisplayInfo()
|
||||
{
|
||||
|
||||
_UpdateDisplayDeviceList();
|
||||
_UpdateMonitorInfoMap();
|
||||
}
|
||||
|
||||
void SceenManager::_UpdateDisplayDeviceList()
|
||||
{
|
||||
spdlog::info("=====GetInfoByEnumDisplayDevices start=====");
|
||||
DISPLAY_DEVICE displayDevice;
|
||||
displayDevice.cb = sizeof(DISPLAY_DEVICE);
|
||||
DWORD deviceIndex = 0;
|
||||
|
||||
while (EnumDisplayDevices(nullptr, deviceIndex, &displayDevice, 0))
|
||||
{
|
||||
spdlog::info("Display Device DeviceName:{0}, DeviceString:{1}, DeviceID:{2}, DeviceKey:{3}.",
|
||||
Wstring2String(displayDevice.DeviceName), Wstring2String(displayDevice.DeviceString),
|
||||
Wstring2String(displayDevice.DeviceID), Wstring2String(displayDevice.DeviceKey));
|
||||
_displayDeviceList.push_back(displayDevice);
|
||||
deviceIndex++;
|
||||
}
|
||||
|
||||
spdlog::info("=====GetInfoByEnumDisplayDevices end=====");
|
||||
}
|
||||
|
||||
BOOL SceenManager::_EnumMonitorProc(HMONITOR hMonitor)
|
||||
{
|
||||
MONITORINFOEX monitorInfo;
|
||||
monitorInfo.cbSize = sizeof(MONITORINFOEX);
|
||||
if (GetMonitorInfo(hMonitor, &monitorInfo))
|
||||
{
|
||||
// 输出友好名称
|
||||
spdlog::info("_UpdateMonitorInfoMap, szDevice:{0}, right:{1}, bottom:{2}", Wchar2String(monitorInfo.szDevice),
|
||||
monitorInfo.rcMonitor.right, monitorInfo.rcMonitor.bottom);
|
||||
}
|
||||
auto it = SceenManager::_hMonitorInfoMap.find(hMonitor);
|
||||
if (it != SceenManager::_hMonitorInfoMap.end())
|
||||
{
|
||||
// 键已经存在,表示存在重复
|
||||
// 在这里处理重复的情况
|
||||
}
|
||||
else
|
||||
{
|
||||
SceenManager::_hMonitorInfoMap.insert(std::make_pair(hMonitor, monitorInfo));
|
||||
// 键不存在,表示没有重复
|
||||
// 在这里处理非重复的情况
|
||||
}
|
||||
|
||||
DISPLAYCONFIG_TARGET_DEVICE_NAME targetDeviceName = {};
|
||||
targetDeviceName.header.size = sizeof(targetDeviceName);
|
||||
|
||||
// 获取指定 HMONITOR 的目标设备名称信息
|
||||
if (DisplayConfigGetDeviceInfo(&targetDeviceName.header) == ERROR_SUCCESS)
|
||||
{
|
||||
spdlog::info("_UpdateMonitorInfoMap, monitorDevicePath:{0}, monitorFriendlyDeviceName:{1}",
|
||||
Wchar2String(targetDeviceName.monitorDevicePath), Wchar2String(targetDeviceName.monitorFriendlyDeviceName));
|
||||
|
||||
// 获取指定 HMONITOR 的分辨率信息
|
||||
DEVMODE dm;
|
||||
dm.dmSize = sizeof(DEVMODE);
|
||||
dm.dmDriverExtra = 0;
|
||||
|
||||
if (EnumDisplaySettings(targetDeviceName.monitorDevicePath, ENUM_CURRENT_SETTINGS, &dm) != 0)
|
||||
{
|
||||
spdlog::info("Resolution:{0}x{1}", dm.dmPelsWidth, dm.dmPelsHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
spdlog::info(L"Failed to get display resolution.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
spdlog::info("Failed to get display device info.");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK SceenManager::EnumMonitorsProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
|
||||
{
|
||||
return ((SceenManager*)dwData)->_EnumMonitorProc(hMonitor);
|
||||
}
|
||||
|
||||
void SceenManager::_UpdateMonitorInfoMap()
|
||||
{
|
||||
spdlog::info("=====GetInfoByEnumDisplayMonitors start=====");
|
||||
// 枚举显示器
|
||||
EnumDisplayMonitors(nullptr, nullptr, EnumMonitorsProc, reinterpret_cast<LPARAM>(this));
|
||||
spdlog::info("=====GetInfoByEnumDisplayMonitors end=====");
|
||||
}
|
||||
|
@ -7,11 +7,15 @@
|
||||
class SceenManager
|
||||
{
|
||||
public:
|
||||
SceenManager();
|
||||
~SceenManager();
|
||||
void UpdateDisplayInfo();
|
||||
|
||||
private:
|
||||
void _UpdateDisplayDeviceList();
|
||||
void _UpdateMonitorInfoMap();
|
||||
static BOOL CALLBACK EnumMonitorsProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
|
||||
BOOL _EnumMonitorProc(HMONITOR hMonitor);
|
||||
|
||||
std::vector<DISPLAY_DEVICE> _displayDeviceList;
|
||||
std::map<HMONITOR, MONITORINFOEX> _hMonitorInfoMap;
|
||||
|
@ -7,9 +7,10 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <spdlog.h>
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
#include "Utils/CmdUtil.h"
|
||||
#include "Video/ScreenManager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -17,7 +18,8 @@ int main()
|
||||
{
|
||||
const std::string command = "wmic desktopmonitor get PNPDeviceId,ScreenWidth,ScreenHeight";
|
||||
const std::string command_output = CmdUtil::ExecuteCommand(command);
|
||||
|
||||
SceenManager sceen_manager;
|
||||
sceen_manager.UpdateDisplayInfo();
|
||||
}
|
||||
|
||||
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
|
||||
|
@ -89,7 +89,7 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include\third_lib\;$(ProjectDir)include\third_lib\spdlog\;.</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include\third_lib\;.</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
@ -147,6 +147,7 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Audio\AudioManager.cpp" />
|
||||
<ClCompile Include="Utils\CmdUtil.cpp" />
|
||||
<ClCompile Include="Utils\Log.cpp" />
|
||||
<ClCompile Include="Utils\SysInfoUtil.cpp" />
|
||||
<ClCompile Include="Utils\TimeUtil.cpp" />
|
||||
<ClCompile Include="Video\ScreenManager.cpp" />
|
||||
@ -157,6 +158,8 @@
|
||||
<ClInclude Include="Audio\AudioManager.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="Utils\CmdUtil.h" />
|
||||
<ClInclude Include="Utils\Log.h" />
|
||||
<ClInclude Include="Utils\StringUtil.h" />
|
||||
<ClInclude Include="Utils\SysInfoUtil.h" />
|
||||
<ClInclude Include="Utils\TimeUtil.h" />
|
||||
<ClInclude Include="Video\ScreenManager.h" />
|
||||
|
@ -33,6 +33,9 @@
|
||||
<ClCompile Include="Utils\TimeUtil.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Utils\Log.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Audio\AudioEnum.h">
|
||||
@ -56,5 +59,11 @@
|
||||
<ClInclude Include="Utils\TimeUtil.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Utils\Log.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Utils\StringUtil.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,363 +0,0 @@
|
||||
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
|
||||
// spdlog main header file.
|
||||
// see example.cpp for usage example
|
||||
|
||||
#ifndef SPDLOG_H
|
||||
#define SPDLOG_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <spdlog/common.h>
|
||||
#include <spdlog/details/registry.h>
|
||||
#include <spdlog/logger.h>
|
||||
#include <spdlog/version.h>
|
||||
#include <spdlog/details/synchronous_factory.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace spdlog {
|
||||
|
||||
using default_factory = synchronous_factory;
|
||||
|
||||
// Create and register a logger with a templated sink type
|
||||
// The logger's level, formatter and flush level will be set according the
|
||||
// global settings.
|
||||
//
|
||||
// Example:
|
||||
// spdlog::create<daily_file_sink_st>("logger_name", "dailylog_filename", 11, 59);
|
||||
template<typename Sink, typename... SinkArgs>
|
||||
inline std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs &&...sink_args)
|
||||
{
|
||||
return default_factory::create<Sink>(std::move(logger_name), std::forward<SinkArgs>(sink_args)...);
|
||||
}
|
||||
|
||||
// Initialize and register a logger,
|
||||
// formatter and flush level will be set according the global settings.
|
||||
//
|
||||
// Useful for initializing manually created loggers with the global settings.
|
||||
//
|
||||
// Example:
|
||||
// auto mylogger = std::make_shared<spdlog::logger>("mylogger", ...);
|
||||
// spdlog::initialize_logger(mylogger);
|
||||
SPDLOG_API void initialize_logger(std::shared_ptr<logger> logger);
|
||||
|
||||
// Return an existing logger or nullptr if a logger with such name doesn't
|
||||
// exist.
|
||||
// example: spdlog::get("my_logger")->info("hello {}", "world");
|
||||
SPDLOG_API std::shared_ptr<logger> get(const std::string &name);
|
||||
|
||||
// Set global formatter. Each sink in each logger will get a clone of this object
|
||||
SPDLOG_API void set_formatter(std::unique_ptr<spdlog::formatter> formatter);
|
||||
|
||||
// Set global format string.
|
||||
// example: spdlog::set_pattern("%Y-%m-%d %H:%M:%S.%e %l : %v");
|
||||
SPDLOG_API void set_pattern(std::string pattern, pattern_time_type time_type = pattern_time_type::local);
|
||||
|
||||
// enable global backtrace support
|
||||
SPDLOG_API void enable_backtrace(size_t n_messages);
|
||||
|
||||
// disable global backtrace support
|
||||
SPDLOG_API void disable_backtrace();
|
||||
|
||||
// call dump backtrace on default logger
|
||||
SPDLOG_API void dump_backtrace();
|
||||
|
||||
// Get global logging level
|
||||
SPDLOG_API level::level_enum get_level();
|
||||
|
||||
// Set global logging level
|
||||
SPDLOG_API void set_level(level::level_enum log_level);
|
||||
|
||||
// Determine whether the default logger should log messages with a certain level
|
||||
SPDLOG_API bool should_log(level::level_enum lvl);
|
||||
|
||||
// Set global flush level
|
||||
SPDLOG_API void flush_on(level::level_enum log_level);
|
||||
|
||||
// Start/Restart a periodic flusher thread
|
||||
// Warning: Use only if all your loggers are thread safe!
|
||||
template<typename Rep, typename Period>
|
||||
inline void flush_every(std::chrono::duration<Rep, Period> interval)
|
||||
{
|
||||
details::registry::instance().flush_every(interval);
|
||||
}
|
||||
|
||||
// Set global error handler
|
||||
SPDLOG_API void set_error_handler(void (*handler)(const std::string &msg));
|
||||
|
||||
// Register the given logger with the given name
|
||||
SPDLOG_API void register_logger(std::shared_ptr<logger> logger);
|
||||
|
||||
// Apply a user defined function on all registered loggers
|
||||
// Example:
|
||||
// spdlog::apply_all([&](std::shared_ptr<spdlog::logger> l) {l->flush();});
|
||||
SPDLOG_API void apply_all(const std::function<void(std::shared_ptr<logger>)> &fun);
|
||||
|
||||
// Drop the reference to the given logger
|
||||
SPDLOG_API void drop(const std::string &name);
|
||||
|
||||
// Drop all references from the registry
|
||||
SPDLOG_API void drop_all();
|
||||
|
||||
// stop any running threads started by spdlog and clean registry loggers
|
||||
SPDLOG_API void shutdown();
|
||||
|
||||
// Automatic registration of loggers when using spdlog::create() or spdlog::create_async
|
||||
SPDLOG_API void set_automatic_registration(bool automatic_registration);
|
||||
|
||||
// API for using default logger (stdout_color_mt),
|
||||
// e.g: spdlog::info("Message {}", 1);
|
||||
//
|
||||
// The default logger object can be accessed using the spdlog::default_logger():
|
||||
// For example, to add another sink to it:
|
||||
// spdlog::default_logger()->sinks().push_back(some_sink);
|
||||
//
|
||||
// The default logger can replaced using spdlog::set_default_logger(new_logger).
|
||||
// For example, to replace it with a file logger.
|
||||
//
|
||||
// IMPORTANT:
|
||||
// The default API is thread safe (for _mt loggers), but:
|
||||
// set_default_logger() *should not* be used concurrently with the default API.
|
||||
// e.g do not call set_default_logger() from one thread while calling spdlog::info() from another.
|
||||
|
||||
SPDLOG_API std::shared_ptr<spdlog::logger> default_logger();
|
||||
|
||||
SPDLOG_API spdlog::logger *default_logger_raw();
|
||||
|
||||
SPDLOG_API void set_default_logger(std::shared_ptr<spdlog::logger> default_logger);
|
||||
|
||||
// Initialize logger level based on environment configs.
|
||||
//
|
||||
// Useful for applying SPDLOG_LEVEL to manually created loggers.
|
||||
//
|
||||
// Example:
|
||||
// auto mylogger = std::make_shared<spdlog::logger>("mylogger", ...);
|
||||
// spdlog::apply_logger_env_levels(mylogger);
|
||||
SPDLOG_API void apply_logger_env_levels(std::shared_ptr<logger> logger);
|
||||
|
||||
template<typename... Args>
|
||||
inline void log(source_loc source, level::level_enum lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(source, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void log(level::level_enum lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void trace(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->trace(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void debug(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->debug(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void info(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->info(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void warn(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->warn(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void error(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->error(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void critical(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->critical(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void log(source_loc source, level::level_enum lvl, const T &msg)
|
||||
{
|
||||
default_logger_raw()->log(source, lvl, msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void log(level::level_enum lvl, const T &msg)
|
||||
{
|
||||
default_logger_raw()->log(lvl, msg);
|
||||
}
|
||||
|
||||
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||
template<typename... Args>
|
||||
inline void log(source_loc source, level::level_enum lvl, wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(source, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void log(level::level_enum lvl, wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void trace(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->trace(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void debug(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->debug(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void info(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->info(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void warn(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->warn(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void error(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->error(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void critical(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->critical(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
inline void trace(const T &msg)
|
||||
{
|
||||
default_logger_raw()->trace(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void debug(const T &msg)
|
||||
{
|
||||
default_logger_raw()->debug(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void info(const T &msg)
|
||||
{
|
||||
default_logger_raw()->info(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void warn(const T &msg)
|
||||
{
|
||||
default_logger_raw()->warn(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void error(const T &msg)
|
||||
{
|
||||
default_logger_raw()->error(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void critical(const T &msg)
|
||||
{
|
||||
default_logger_raw()->critical(msg);
|
||||
}
|
||||
|
||||
} // namespace spdlog
|
||||
|
||||
//
|
||||
// enable/disable log calls at compile time according to global level.
|
||||
//
|
||||
// define SPDLOG_ACTIVE_LEVEL to one of those (before including spdlog.h):
|
||||
// SPDLOG_LEVEL_TRACE,
|
||||
// SPDLOG_LEVEL_DEBUG,
|
||||
// SPDLOG_LEVEL_INFO,
|
||||
// SPDLOG_LEVEL_WARN,
|
||||
// SPDLOG_LEVEL_ERROR,
|
||||
// SPDLOG_LEVEL_CRITICAL,
|
||||
// SPDLOG_LEVEL_OFF
|
||||
//
|
||||
|
||||
#ifndef SPDLOG_NO_SOURCE_LOC
|
||||
# define SPDLOG_LOGGER_CALL(logger, level, ...) \
|
||||
(logger)->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_CALL(logger, level, ...) (logger)->log(spdlog::source_loc{}, level, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
|
||||
# define SPDLOG_LOGGER_TRACE(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::trace, __VA_ARGS__)
|
||||
# define SPDLOG_TRACE(...) SPDLOG_LOGGER_TRACE(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_TRACE(logger, ...) (void)0
|
||||
# define SPDLOG_TRACE(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG
|
||||
# define SPDLOG_LOGGER_DEBUG(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::debug, __VA_ARGS__)
|
||||
# define SPDLOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_DEBUG(logger, ...) (void)0
|
||||
# define SPDLOG_DEBUG(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO
|
||||
# define SPDLOG_LOGGER_INFO(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::info, __VA_ARGS__)
|
||||
# define SPDLOG_INFO(...) SPDLOG_LOGGER_INFO(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_INFO(logger, ...) (void)0
|
||||
# define SPDLOG_INFO(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_WARN
|
||||
# define SPDLOG_LOGGER_WARN(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::warn, __VA_ARGS__)
|
||||
# define SPDLOG_WARN(...) SPDLOG_LOGGER_WARN(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_WARN(logger, ...) (void)0
|
||||
# define SPDLOG_WARN(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_ERROR
|
||||
# define SPDLOG_LOGGER_ERROR(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::err, __VA_ARGS__)
|
||||
# define SPDLOG_ERROR(...) SPDLOG_LOGGER_ERROR(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_ERROR(logger, ...) (void)0
|
||||
# define SPDLOG_ERROR(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_CRITICAL
|
||||
# define SPDLOG_LOGGER_CRITICAL(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::critical, __VA_ARGS__)
|
||||
# define SPDLOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_CRITICAL(logger, ...) (void)0
|
||||
# define SPDLOG_CRITICAL(...) (void)0
|
||||
#endif
|
||||
|
||||
#ifdef SPDLOG_HEADER_ONLY
|
||||
# include "spdlog-inl.h"
|
||||
#endif
|
||||
|
||||
#endif // SPDLOG_H
|
@ -6,3 +6,4 @@
|
||||
#include <shlwapi.h>
|
||||
#include <Psapi.h>
|
||||
#include <Shellapi.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user