2018-05-03 13:47:57 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-12-05 17:58:23 +00:00
|
|
|
// SCSI Target Emulator PiSCSI
|
2018-05-03 13:47:57 +00:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Powered by XM6 TypeG Technology.
|
2020-07-04 14:57:44 +00:00
|
|
|
// Copyright (C) 2016-2020 GIMONS
|
2020-10-19 12:31:06 +00:00
|
|
|
// Copyright (C) 2020 akuker
|
2018-05-03 13:47:57 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-09-25 21:49:24 +00:00
|
|
|
#pragma once
|
2018-05-03 13:47:57 +00:00
|
|
|
|
2020-10-19 12:31:06 +00:00
|
|
|
#include "spdlog/spdlog.h"
|
2023-02-05 04:51:35 +00:00
|
|
|
#include <array>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
using namespace std;
|
2020-10-19 12:31:06 +00:00
|
|
|
|
2022-09-25 21:49:24 +00:00
|
|
|
static const int LOGBUF_SIZE = 512;
|
|
|
|
|
2023-02-05 04:51:35 +00:00
|
|
|
#define SPDLOGWRAPPER(loglevel, ...) \
|
|
|
|
{ \
|
|
|
|
char logbuf[LOGBUF_SIZE]; \
|
|
|
|
snprintf(logbuf, sizeof(logbuf), __VA_ARGS__); \
|
|
|
|
spdlog::log(loglevel, logbuf); \
|
|
|
|
};
|
2020-10-19 12:31:06 +00:00
|
|
|
|
2021-02-07 19:00:48 +00:00
|
|
|
#define LOGTRACE(...) SPDLOGWRAPPER(spdlog::level::trace, __VA_ARGS__)
|
|
|
|
#define LOGDEBUG(...) SPDLOGWRAPPER(spdlog::level::debug, __VA_ARGS__)
|
|
|
|
#define LOGINFO(...) SPDLOGWRAPPER(spdlog::level::info, __VA_ARGS__)
|
|
|
|
#define LOGWARN(...) SPDLOGWRAPPER(spdlog::level::warn, __VA_ARGS__)
|
|
|
|
#define LOGERROR(...) SPDLOGWRAPPER(spdlog::level::err, __VA_ARGS__)
|
2023-02-05 04:51:35 +00:00
|
|
|
|
|
|
|
class piscsi_log_level
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static bool set_log_level(const string&);
|
|
|
|
static spdlog::level::level_enum get_log_level()
|
|
|
|
{
|
|
|
|
return current_log_level;
|
|
|
|
};
|
|
|
|
static const spdlog::string_view_t& get_log_level_str()
|
|
|
|
{
|
|
|
|
return spdlog_names[current_log_level];
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
static spdlog::level::level_enum current_log_level;
|
|
|
|
static std::array<spdlog::string_view_t, (int)spdlog::level::level_enum::n_levels> spdlog_names;
|
|
|
|
};
|