hyperlane-plugin-logger 23.3.1

A logging plugin for the Hyperlane framework, writing the log of a server to the console, to a file, or to both.
Documentation
/// Default bounded non-blocking log channel capacity for background file writes.
pub const DEFAULT_LOGGER_CHANNEL_CAPACITY: usize = 16_384;

/// Default buffer size in bytes for the background buffered file writer.
pub(crate) const LOGGER_FILE_BUFFER_BYTES: usize = 64 * 1024;

/// Background writer thread name.
pub(crate) const LOGGER_WRITER_THREAD_NAME: &str = "hyperlane-logger";

/// Debug struct label for [`crate::LoggerConfig`].
pub(crate) const DEBUG_LOGGER_CONFIG: &str = "LoggerConfig";

/// Debug field name for log level.
pub(crate) const DEBUG_FIELD_LEVEL: &str = "level";

/// Debug field name for output file path.
pub(crate) const DEBUG_FIELD_FILE: &str = "file";

/// Debug field name for console flag.
pub(crate) const DEBUG_FIELD_CONSOLE: &str = "console";

/// Debug field name for output format.
pub(crate) const DEBUG_FIELD_FORMAT: &str = "format";

/// Debug field name for channel capacity.
pub(crate) const DEBUG_FIELD_CHANNEL_CAPACITY: &str = "channel_capacity";

/// Debug field name indicating custom sink presence.
pub(crate) const DEBUG_FIELD_HAS_SINK: &str = "has_sink";

/// The name of the attribute that carries the moment a request arrived.
pub(crate) const ATTRIBUTE_STARTED_AT: &str = "hyperlane-plugin-logger-started-at";

/// The text that stands for a request that carries no path.
pub(crate) const PATH_UNKNOWN: &str = "-";

/// The text that stands for a request that carries no method.
pub(crate) const METHOD_UNKNOWN: &str = "-";

/// Error reported when the logger configuration was already installed.
pub(crate) const ERROR_CONFIG_ALREADY_SET: &str = "the logger configuration was already set";

/// Error reported when the log writer was already installed.
pub(crate) const ERROR_FILE_ALREADY_SET: &str = "the log file was already set";

/// Error reported when a global `log` implementation was already installed.
pub(crate) const ERROR_LOGGER_ALREADY_INSTALLED: &str = "a logger was already installed";

/// Replacement sequence emitted for carriage returns in log records.
pub(crate) const ESCAPED_CR: &str = "\\r";

/// Replacement sequence emitted for line feeds in log records.
pub(crate) const ESCAPED_LF: &str = "\\n";

/// Replacement sequence emitted for ANSI escape bytes in log records.
pub(crate) const ESCAPED_ESC: &str = "\\x1b";

/// Replacement sequence emitted for double quotes in JSON log records.
pub(crate) const ESCAPED_QUOTE: &str = "\\\"";

/// Replacement sequence emitted for backslashes in JSON log records.
pub(crate) const ESCAPED_BACKSLASH: &str = "\\\\";

/// Replacement sequence emitted for tabs in JSON log records.
pub(crate) const ESCAPED_TAB: &str = "\\t";

/// Prebuilt JSON record prefixes combining `{"level":"<LEVEL>","target":"` for each log level.
pub(crate) const JSON_PREFIX_ERROR: &str = "{\"level\":\"ERROR\",\"target\":\"";

/// Prebuilt JSON record prefix for `WARN` records.
pub(crate) const JSON_PREFIX_WARN: &str = "{\"level\":\"WARN\",\"target\":\"";

/// Prebuilt JSON record prefix for `INFO` records.
pub(crate) const JSON_PREFIX_INFO: &str = "{\"level\":\"INFO\",\"target\":\"";

/// Prebuilt JSON record prefix for `DEBUG` records.
pub(crate) const JSON_PREFIX_DEBUG: &str = "{\"level\":\"DEBUG\",\"target\":\"";

/// Prebuilt JSON record prefix for `TRACE` records.
pub(crate) const JSON_PREFIX_TRACE: &str = "{\"level\":\"TRACE\",\"target\":\"";

/// Prebuilt plain-text record prefix for `ERROR` records.
pub(crate) const PLAIN_PREFIX_ERROR: &str = "ERROR ";

/// Prebuilt plain-text record prefix for `WARN` records.
pub(crate) const PLAIN_PREFIX_WARN: &str = "WARN ";

/// Prebuilt plain-text record prefix for `INFO` records.
pub(crate) const PLAIN_PREFIX_INFO: &str = "INFO ";

/// Prebuilt plain-text record prefix for `DEBUG` records.
pub(crate) const PLAIN_PREFIX_DEBUG: &str = "DEBUG ";

/// Prebuilt plain-text record prefix for `TRACE` records.
pub(crate) const PLAIN_PREFIX_TRACE: &str = "TRACE ";

/// JSON record separator between target and message fields.
pub(crate) const JSON_SEP_MESSAGE: &str = "\",\"message\":\"";

/// JSON record closing suffix.
pub(crate) const JSON_SUFFIX: &str = "\"}";

/// SWAR high-bit mask for 8-byte parallel ASCII classification.
pub(crate) const SWAR_HIGH_BITS: u64 = 0x8080_8080_8080_8080;

/// SWAR broadcast of `0x20` for `< 0x20` control byte detection.
pub(crate) const SWAR_SPACE_BROADCAST: u64 = 0x2020_2020_2020_2020;

/// SWAR broadcast of `0x01` for exact byte and `0x7f` detection.
pub(crate) const SWAR_ONES_BROADCAST: u64 = 0x0101_0101_0101_0101;

/// SWAR broadcast of `b'"'` (`0x22`) for JSON quote detection.
pub(crate) const SWAR_QUOTE_BROADCAST: u64 = 0x2222_2222_2222_2222;

/// SWAR broadcast of `b'\\'` (`0x5c`) for JSON backslash detection.
pub(crate) const SWAR_BACKSLASH_BROADCAST: u64 = 0x5c5c_5c5c_5c5c_5c5c;

/// ASCII double quote byte (`"`).
pub(crate) const ASCII_QUOTE: u8 = b'"';

/// ASCII backslash byte (`\`).
pub(crate) const ASCII_BACKSLASH: u8 = b'\\';