ADTF File Library
Loading...
Searching...
No Matches
log.h File Reference
#include <string_view>
#include <cstdint>
#include <string>
#include <chrono>
Include dependency graph for log.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  adtf_file::SourceLocation
 Identifies the source code location where a log message was emitted. More...
 
struct  adtf_file::LogEntry
 Bundles all data associated with a single log event. More...
 
class  adtf_file::Logger
 Abstract sink for log messages produced by the adtf_file library. More...
 

Namespaces

namespace  adtf_file
 namespace for ADTF File library
 

Macros

#define ADTF_FILE_LOG(__level, __message)
 Emit a log message at an arbitrary level.
 
#define ADTF_FILE_LOG_DUMP(__message)
 Emit a adtf_file::LogLevel::Dump message.
 
#define ADTF_FILE_LOG_DETAIL(__message)
 Emit a adtf_file::LogLevel::Detail message.
 
#define ADTF_FILE_LOG_INFO(__message)
 Emit a adtf_file::LogLevel::Info message.
 
#define ADTF_FILE_LOG_WARNING(__message)
 Emit a adtf_file::LogLevel::Warning message.
 
#define ADTF_FILE_LOG_ERROR(__message)
 Emit a adtf_file::LogLevel::Error message.
 

Enumerations

enum class  adtf_file::LogLevel : uint8_t {
  adtf_file::None = 0 , adtf_file::Error = 10 , adtf_file::Warning = 20 , adtf_file::Info = 30 ,
  adtf_file::Detail = 35 , adtf_file::Dump = 40 , adtf_file::Debug = Dump , adtf_file::All = 0xFF
}
 Severity levels for log messages, ordered from least to most verbose. More...
 

Functions

Loggeradtf_file::getLogger () noexcept
 Returns the active logger used by the library.
 
Loggeradtf_file::getDefaultLogger () noexcept
 Returns the built-in default logger.
 
bool adtf_file::getTerminalColorSupport (FILE *output) noexcept
 Queries whether the current terminal supports ANSI color sequences.
 
std::string adtf_file::defaultLogFormat (std::chrono::system_clock::time_point timestamp, LogLevel log_level, std::string_view message, SourceLocation location, bool bWithColor) noexcept
 Formats a log event into a human-readable string.
 
void adtfFileSetLogger (adtf_file::Logger *logger)
 Injects a host-provided logger into the plugin.
 

Detailed Description

Copyright 2026 Digitalwerk GmbH.

This Source Code Form is subject to the terms of the Mozilla
Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice.

You may add additional accurate notices of copyright ownership.

Macro Definition Documentation

◆ ADTF_FILE_LOG

#define ADTF_FILE_LOG ( __level,
__message )
Value:
adtf_file::getLogger().log(std::chrono::system_clock::now(), __level, __message, \
ADTF_FILE_CURRENT_SOURCE_LOCATION())
virtual void log(std::chrono::system_clock::time_point timestamp, LogLevel log_level, std::string_view message, SourceLocation location) noexcept=0
Emit a single log event.
Logger & getLogger() noexcept
Returns the active logger used by the library.

Emit a log message at an arbitrary level.

Captures the current source location and wall-clock time automatically.

Parameters
__levelA adtf_file::LogLevel value.
__messageA std::string_view -compatible message.

◆ ADTF_FILE_LOG_DETAIL

#define ADTF_FILE_LOG_DETAIL ( __message)
Value:
#define ADTF_FILE_LOG(__level, __message)
Emit a log message at an arbitrary level.
Definition log.h:148
@ Detail
More detailed operational messages for diagnostics.
Definition log.h:34

Emit a adtf_file::LogLevel::Detail message.

Parameters
__messageLog message.

◆ ADTF_FILE_LOG_DUMP

#define ADTF_FILE_LOG_DUMP ( __message)
Value:
@ Dump
Verbose data dumps for deep troubleshooting.
Definition log.h:35

Emit a adtf_file::LogLevel::Dump message.

Parameters
__messageLog message.

◆ ADTF_FILE_LOG_ERROR

#define ADTF_FILE_LOG_ERROR ( __message)
Value:
@ Error
Unrecoverable errors that require immediate attention.
Definition log.h:31

Emit a adtf_file::LogLevel::Error message.

Parameters
__messageLog message.

◆ ADTF_FILE_LOG_INFO

#define ADTF_FILE_LOG_INFO ( __message)
Value:
@ Info
General informational messages about normal operation.
Definition log.h:33

Emit a adtf_file::LogLevel::Info message.

Parameters
__messageLog message.

◆ ADTF_FILE_LOG_WARNING

#define ADTF_FILE_LOG_WARNING ( __message)
Value:
@ Warning
Potentially harmful situations that do not abort processing.
Definition log.h:32

Emit a adtf_file::LogLevel::Warning message.

Parameters
__messageLog message.

Function Documentation

◆ adtfFileSetLogger()

void adtfFileSetLogger ( adtf_file::Logger * logger)

Injects a host-provided logger into the plugin.

Called by the host application after loading a plugin (via adtf_file::loadPlugin) so that all log output from the plugin is forwarded to the host's logger rather than the plugin's built-in default.

Passing nullptr resets the plugin to its default logger.

Parameters
loggerPointer to the adtf_file::Logger implementation provided by the host, or nullptr to restore the default.
See also
adtf_file::getLogger(), adtf_file::loadPlugin()