include/AclLog.h

include/AclLog.h

Namespaces

Name
AclLog
A namespace for logging utilities.

Classes

Name
classAclLog::CommandLogFormatter
This class is used to format log entries for Rendering Engine commands.

Source code

// Copyright (c) 2022, Edgeware AB. All rights reserved.

#pragma once

#include <filesystem>
#include <string>

#include <spdlog/details/log_msg.h>
#include <spdlog/fmt/fmt.h>
#include <spdlog/formatter.h>
#include <spdlog/pattern_formatter.h>

namespace AclLog {

enum class Level {
    kTrace,    // Detailed diagnostics (for development only)
    kDebug,    // Messages intended for debugging only
    kInfo,     // Messages about normal behavior (default log level)
    kWarning,  // Warnings (functionality intact)
    kError,    // Recoverable errors (functionality impaired)
    kCritical, // Unrecoverable errors (application must stop)
    kOff       // Turns off all logging
};

void init(const std::string& name);

void initCommandLog(const std::string& name);

void setLevel(Level level);

void logCommand(const std::string& command);

AclLog::Level getLogLevel();

size_t getMaxFileSize();

size_t getMaxLogRotations();

std::filesystem::path getLogFileFullPath(const std::string& name);

class CommandLogFormatter : public spdlog::formatter {
public:
    CommandLogFormatter();
    void format(const spdlog::details::log_msg& msg, spdlog::memory_buf_t& dest) override;
    [[nodiscard]] std::unique_ptr<spdlog::formatter> clone() const override;

private:
    std::unique_ptr<spdlog::pattern_formatter> mCommandLogPattern;
};

} // namespace AclLog

Updated on 2023-06-13 at 17:00:17 +0200