Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup skeleton audit log #310

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/common/shared/logging/include/logging/LogUtils.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@

#include <plog/Severity.h>

enum class LogInstanceId : int {
// Default logger is 0 and is omitted from this enumeration.
Console = 1,
File = 2,
Audit = 3,
};

#define AUDIT_LOGN LOG_(static_cast<int>(LogInstanceId::Audit), plog::none)
#define AUDIT_LOGF LOG_(static_cast<int>(LogInstanceId::Audit), plog::fatal)
#define AUDIT_LOGE LOG_(static_cast<int>(LogInstanceId::Audit), plog::error)
#define AUDIT_LOGW LOG_(static_cast<int>(LogInstanceId::Audit), plog::warning)
#define AUDIT_LOGI LOG_(static_cast<int>(LogInstanceId::Audit), plog::info)
#define AUDIT_LOGD LOG_(static_cast<int>(LogInstanceId::Audit), plog::debug)
#define AUDIT_LOGV LOG_(static_cast<int>(LogInstanceId::Audit), plog::verbose)
corbin-phipps marked this conversation as resolved.
Show resolved Hide resolved

namespace logging
{
/**
Expand Down
17 changes: 10 additions & 7 deletions src/linux/server/Main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ using namespace Microsoft::Net::Remote;
using namespace Microsoft::Net::Remote::Service;
using namespace Microsoft::Net::Wifi;

enum class LogInstanceId : int {
// Default logger is 0 and is omitted from this enumeration.
Console = 1,
File = 2,
};

namespace
{
/**
Expand Down Expand Up @@ -89,7 +83,14 @@ main(int argc, char *argv[])

// Create file and console log appenders.
static plog::ColorConsoleAppender<plog::MessageOnlyFormatter> colorConsoleAppender{};
static plog::RollingFileAppender<plog::TxtFormatter> rollingFileAppender(logging::GetLogName("server").c_str());
std::string logFilePath = "/usr/local/";
corbin-phipps marked this conversation as resolved.
Show resolved Hide resolved
corbin-phipps marked this conversation as resolved.
Show resolved Hide resolved
logFilePath += logging::GetLogName("server");
static plog::RollingFileAppender<plog::TxtFormatter> rollingFileAppender(logFilePath.c_str());

// Create the audit log file appender.
std::string auditLogFilePath = "/usr/local/";
auditLogFilePath += logging::GetLogName("audit");
static plog::RollingFileAppender<plog::TxtFormatter> auditLogRollingFileAppender(auditLogFilePath.c_str());

// Parse command line arguments.
auto configuration = NetRemoteServerConfiguration::FromCommandLineArguments(argc, argv);
Expand All @@ -102,8 +103,10 @@ main(int argc, char *argv[])
plog::init<std::to_underlying(LogInstanceId::File)>(logSeverity, &rollingFileAppender);
plog::init(logSeverity).addAppender(plog::get<std::to_underlying(LogInstanceId::File)>());
}
plog::init<std::to_underlying(LogInstanceId::Audit)>(logSeverity, &auditLogRollingFileAppender);

LOGN << std::format("Netremote server starting (log level={})", magic_enum::enum_name(logSeverity));
AUDIT_LOGN << std::format("Netremote server starting (log level={})", magic_enum::enum_name(logSeverity));

// Create an access point manager and discovery agent.
auto accessPointManager = AccessPointManager::Create();
Expand Down
Loading