2022-11-11 20:08:48 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-12-05 17:58:23 +00:00
|
|
|
// SCSI Target Emulator PiSCSI
|
2022-11-11 20:08:48 +00:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
2023-10-15 06:38:15 +00:00
|
|
|
// Copyright (C) 2022-2023 Uwe Seimet
|
2022-11-11 20:08:48 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "device_logger.h"
|
|
|
|
|
|
|
|
using namespace std;
|
2023-10-15 06:38:15 +00:00
|
|
|
using namespace spdlog;
|
2022-11-11 20:08:48 +00:00
|
|
|
|
|
|
|
void DeviceLogger::Trace(const string& message) const
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
Log(level::trace, message);
|
2022-11-11 20:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceLogger::Debug(const string& message) const
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
Log(level::debug, message);
|
2022-11-11 20:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceLogger::Info(const string& message) const
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
Log(level::info, message);
|
2022-11-11 20:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceLogger::Warn(const string& message) const
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
Log(level::warn, message);
|
2022-11-11 20:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceLogger::Error(const string& message) const
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
Log(level::err, message);
|
2022-11-11 20:08:48 +00:00
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
void DeviceLogger::Log(level::level_enum level, const string& message) const
|
2022-11-11 20:08:48 +00:00
|
|
|
{
|
2023-11-26 04:25:54 +00:00
|
|
|
if ((log_device_id == -1 || log_device_id == id) && (lun == -1 || log_device_lun == -1 || log_device_lun == lun)) {
|
|
|
|
if (lun == -1) {
|
|
|
|
log(level, "(ID " + to_string(id) + ") - " + message);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
log(level, "(ID:LUN " + to_string(id) + ":" + to_string(lun) + ") - " + message);
|
|
|
|
}
|
|
|
|
}
|
2022-11-11 20:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceLogger::SetIdAndLun(int i, int l)
|
|
|
|
{
|
|
|
|
id = i;
|
|
|
|
lun = l;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceLogger::SetLogIdAndLun(int i, int l)
|
|
|
|
{
|
|
|
|
log_device_id = i;
|
|
|
|
log_device_lun = l;
|
|
|
|
}
|