Logger.cpp

1. Overview

Logger implementation. Formats timestamps and severity labels, serializes concurrent writes and duplicates messages to stderr and an optional log file.

The original source path is:

src/logging/Logger.cpp

2. Role in the Daemon

This file participates in the privileged BastionGuard Secure Connection daemon. It uses the shared bsc models and follows the daemon-wide fallback strategy: optional high-fidelity backends are used when available, while portable polling or stub behavior preserves service startup.


3. Namespaces

  • bsc::logging
  • std::chrono

4. Dependencies and Included Interfaces

  • bsc/logging/Logger.hpp
  • chrono
  • ctime
  • fstream
  • iomanip
  • iostream
  • sstream

5. API and Functions

The file declares or implements the following callable entry points:

  • Logger::instance()
  • Logger::set_level(Level level)
  • Logger::set_utc(bool enabled)
  • Logger::set_microseconds(bool enabled)
  • Logger::set_log_file(const std::string& path)
  • Logger::debug(const std::string& msg)
  • Logger::info(const std::string& msg)
  • Logger::warning(const std::string& msg)
  • Logger::error(const std::string& msg)
  • Logger::log(Level level, const std::string& msg)
  • Logger::timestamp()
  • Logger::level_name(Level level)

6. External Resources and Protocol Values

Relevant paths, endpoints, command names or policy values referenced by this file include:

  • bsc/logging/Logger.hpp

7. Implementation Considerations

  • Shared state is protected by mutexes; callers should avoid holding external locks while invoking callbacks.

8. Source Metrics

MetricValue
File size2028 bytes
Lines62
Detected API entries12
Detected types0