# A sample log configuration file for running in release mode. By default, this configuration splits up log messages to
# three destinations:
#    * Console: For log messages with level INFO and higher
#    * log/base-node/network.log: INFO-level logs related to the comms crate. This file will be quite busy since there
#      are lots of P2P debug messages, and so this traffic is segregated from the application log messages
#    * log/base-node/base_layer.log: Non-comms related INFO-level messages and higher are logged into this file
#    * log/base-node/other.log: Third-party crates' messages will be logged here at an ERROR level
#
#  See https://docs.rs/log4rs/0.8.3/log4rs/encode/pattern/index.html for deciphering the log pattern. The log format
#  used in this sample configuration prints messages as:
#  timestamp [target] LEVEL message
refresh_rate: 30 seconds
appenders:
  # An appender named "stdout" that writes to stdout
  stdout:
    kind: console

    encoder:
      pattern: "{d(%H:%M)} {h({l}):5} {m}{n}"
    filters:
      -
        kind: threshold
        level: warn

  # An appender named "network" that writes to a file with a custom pattern encoder
  network:
    kind: rolling_file
    path: "log/validator-node/network.log"
    policy:
      kind: compound
      trigger:
        kind: size
        limit: 10mb
      roller:
        kind: fixed_window
        base: 1
        count: 5
        pattern: "log/base-node/network.{}.log"
    encoder:
      pattern: "{d(%Y-%m-%d %H:%M:%S.%f)} [{t}] [Thread:{I}] {l:5} {m}{n}"

  message_log:
    kind: rolling_file
    path: "log/validator-node/messages.log"
    policy:
      kind: compound
      trigger:
        kind: size
        limit: 10mb
      roller:
        kind: fixed_window
        base: 1
        count: 5
        pattern: "log/base-node/messages.{}.log"
    encoder:
      pattern: "{d(%Y-%m-%d %H:%M:%S.%f)} [{t}] [Thread:{I}] {l:5} {m}{n}"

  # An appender named "base_layer" that writes to a file with a custom pattern encoder
  base_layer:
    kind: rolling_file
    path: "log/validator-node/base_layer.log"
    policy:
      kind: compound
      trigger:
        kind: size
        limit: 10mb
      roller:
        kind: fixed_window
        base: 1
        count: 5
        pattern: "log/validator-node/base_layer.{}.log"
    encoder:
      pattern: "{d(%Y-%m-%d %H:%M:%S.%f)} [{t}] [Thread:{I}] {l:5} {m}{n}"

  # An appender named "other" that writes to a file with a custom pattern encoder
  other:
    kind: rolling_file
    path: "log/validator-node/other.log"
    policy:
      kind: compound
      trigger:
        kind: size
        limit: 10mb
      roller:
        kind: fixed_window
        base: 1
        count: 5
        pattern: "log/validator-node/other.{}.log"
    encoder:
      pattern: "{d(%Y-%m-%d %H:%M:%S.%f)} [{t}] [Thread:{I}] {l:5} {m}{n}"

# Set the default logging level to "info"
root:
  level: warn
  appenders:
    - stdout

loggers:
  # Route log events common to every application to all appenders
  minotari::application:
    level: info
    appenders:
      - base_layer
      - network
      - other
    additive: false

  # Route log events sent to the "core" logger to the "base_layer" appender
  c:
    level: info
    appenders:
      - base_layer
  minotari:
    level: info
    appenders:
      - base_layer
  messages:
    level: debug
    appenders:
      - message_log
    additive: false

  # Route log events sent to the "wallet" logger to the "base_layer" appender
  wallet:
    level: info
    appenders:
      - base_layer
  # Route log events sent to the "comms" logger to the "network" appender
  comms:
    level: info
    appenders:
      - network
  # Route log events sent to the "p2p" logger to the "network" appender
  p2p:
    level: info
    appenders:
      - network

    # Route log events sent to the "yamux" logger to the "network" appender
  yamux:
    level: info
    appenders:
      - network
  # Route log events sent to the "mio" logger to the "network" appender
  mio:
    level: error
    appenders:
      - network
  # Route log events sent to the "rustyline" logger to the "other" appender
  rustyline:
    level: error
    appenders:
      - other
    additive: false

  # Route log events sent to the "tokio_util" logger to the "other" appender
  tokio_util:
    level: error
    appenders:
      - other

