A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
log.h File Reference

Log levels, log-chunk metadata and the process-wide action log sink. More...

#include <functional>
#include <optional>
#include <string>
#include <string_view>
#include <absl/base/log_severity.h>
#include <absl/status/statusor.h>
#include <absl/time/time.h>
#include "a11/data/types.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  a11::actions::LogOptions
 Everything about a log other than the object being logged. More...
 
struct  a11::actions::LogRecord
 One log as a sink sees it. More...
 

Namespaces

namespace  a11
 
namespace  a11::actions
 

Typedefs

using a11::actions::ActionLogSink = std::function< void(const LogRecord &)>
 What the process does with a log it consumes itself.
 

Enumerations

enum class  a11::actions::LogLevel {
  a11::actions::kDebug , a11::actions::kInfo , a11::actions::kWarning , a11::actions::kError ,
  a11::actions::kCritical
}
 Severity of a log chunk. More...
 

Functions

std::string_view a11::actions::LogLevelName (LogLevel level)
 Canonical lowercase name of level, as written to a chunk.
 
absl::StatusOr< LogLevel > a11::actions::ParseLogLevel (std::string_view name)
 Parses a level name.
 
absl::LogSeverity a11::actions::LogLevelToSeverity (LogLevel level)
 The Abseil severity level is reported at.
 
void a11::actions::SetActionLogSink (ActionLogSink sink)
 Installs sink as the process's action log sink.
 
ActionLogSink a11::actions::GetActionLogSink ()
 Returns the installed sink; never null.
 
void a11::actions::ReportLog (const LogRecord &record)
 Reports record to the installed sink.
 
bool a11::actions::IsTextualLogMimetype (std::string_view mimetype)
 Whether a log payload of mimetype reads as text.
 
std::string a11::actions::LogText (const LogRecord &record)
 record as one line: its payload where that is text, a description of it where it is not.
 
LogRecord a11::actions::LogRecordFromChunk (const data::Chunk &chunk, std::string_view action_name={}, std::string_view action_id={})
 Reads a LogRecord back out of a log chunk.
 

Variables

constexpr LogLevel a11::actions::kDefaultLogLevel = LogLevel::kInfo
 The default level of a log written without one.
 
constexpr std::string_view a11::actions::kLogLevelAttribute = "level"
 Metadata attribute naming the log's level.
 
constexpr std::string_view a11::actions::kLogInternalAttribute = "internal"
 Metadata attribute marking a log not meant for an end user.
 
constexpr std::string_view a11::actions::kLogChannelAttribute = "channel"
 Metadata attribute naming the log's logical channel.
 
constexpr std::string_view a11::actions::kLogFileAttribute = "file"
 Metadata attribute naming the source file the log came from.
 
constexpr std::string_view a11::actions::kLogLinenoAttribute = "lineno"
 Metadata attribute naming the source line the log came from.
 
constexpr std::string_view a11::actions::kLogChildActionAttribute = "a11-child-action"
 Metadata attribute naming the nested action that wrote a log.
 
constexpr std::string_view a11::actions::kLogChildCallIdAttribute
 Metadata attribute naming the nested action call that wrote a log.
 
constexpr std::string_view a11::actions::kLogInternalTrue = "true"
 The value kLogInternalAttribute takes when the log is internal.
 
constexpr std::string_view a11::actions::kLogInternalFalse = "false"
 The value kLogInternalAttribute takes when it is not.
 

Detailed Description

Log levels, log-chunk metadata and the process-wide action log sink.

Action::Log writes a a11::data::Chunk to the reserved a11::actions::kActionLogOutput port. This header defines its levels, metadata, options, and process-wide sink. The default sink forwards records to Abseil logging.