viva_telemetry/log/entry

Log entry type - the core data structure for log messages

Types

A structured log entry

pub type Entry {
  Entry(
    level: level.Level,
    message: String,
    fields: dict.Dict(String, String),
    timestamp: Int,
    context: dict.Dict(String, String),
    source: String,
  )
}

Constructors

  • Entry(
      level: level.Level,
      message: String,
      fields: dict.Dict(String, String),
      timestamp: Int,
      context: dict.Dict(String, String),
      source: String,
    )

    Arguments

    level

    Log level

    message

    Log message

    fields

    Structured fields (key-value pairs)

    timestamp

    Unix timestamp in microseconds

    context

    Inherited context fields

    source

    Optional module/source name

Values

pub fn all_fields(entry: Entry) -> dict.Dict(String, String)

Get all fields (context + entry fields)

pub fn new(
  level: level.Level,
  message: String,
  fields: List(#(String, String)),
) -> Entry

Create a new log entry

pub fn to_console_string(entry: Entry, colored: Bool) -> String

Format entry for console output

pub fn to_json(entry: Entry) -> json.Json

Convert entry to JSON

pub fn to_json_string(entry: Entry) -> String

Convert entry to JSON string

pub fn with_context(
  entry: Entry,
  context: dict.Dict(String, String),
) -> Entry

Add context to entry

pub fn with_field(
  entry: Entry,
  key: String,
  value: String,
) -> Entry

Add a field to entry

pub fn with_source(entry: Entry, source: String) -> Entry

Create entry with source module

Search Document