[go: up one dir, main page]

Logging: Introduce `advertise-levels` for displaying event level

We propose to add a new opt-in feature for logging which makes explicit the level of events, instead of forcing consumer to know about them.

  • For the one-per-line and netstring format, it adds the field level along with the existing hostname, time_stamp, section and event.
  • For the pp-short format, it changes the string prepends to the event to include the level in addition to the timestamp.
  • For the pp_rfc5424 format, it adds the priority value at the very beginning of the log line—reusing the suggested severity number.

We believe this new feature will provide more flexibility to logs consumers. For instance, with this, you can easily setup an alert in your system for any Error or Fatal log emitted by your service. This is not something possible to do today without the developer to adopt a strict naming convention or similar workaround. It can also simplify debugging by allowing to grep errors and warnings.

This is implemented by adding a new query parameter advertise-levels for defining sinks, defaulting to false (the current behavior if it is not set explicitly). This means that it is an opt-in change, that users need to enabled themselves.

Here are examples of the new format with a project I am currently working on.

For pp-short:

Jan 11 17:42:00.374   INFO │ worker started
Jan 11 17:42:00.375 NOTICE │ Tx queue is ready
Jan 11 17:42:00.449 NOTICE │ Floodgate is ready to spam network 0x1f47b
Jan 11 17:42:00.449 NOTICE │   (base_fee_per_gas: 0.000000001)
Jan 11 17:42:00.529   INFO │ Received blueprint 16790339
Jan 11 17:42:00.700   INFO │ Injecting 1 transactions
Jan 11 17:42:00.860   INFO │ Received blueprint 16790340

For the JSON constructed for one-per-line and netstring (pretty-printed for readability):

{
  "fd-sink-item.v0": {
    "level": "notice",
    "hostname": "vanellope",
    "time_stamp": 1736610520.317238,
    "section": ["floodgate"],
    "event": {
      "is_ready.v0": {
        "chain_id": "0x1f47b",
        "base_fee_per_gas":"1000000000"
      }
    }
  }
}

Finally, for the pp_rfc5424 log line:

<005> 2025-01-12T14:22:43.632-00:00 [evm_node.dev.shutting_down_tx_pool] Stopping the tx-pool

Manually testing the MR

  • Build this branch, start a node, witness nothing has changed.
  • Apply this patch, start the EVM node, witness beauty
diff --git a/etherlink/bin_node/main.ml b/etherlink/bin_node/main.ml
index 03e4f130224..62903771a68 100644
--- a/etherlink/bin_node/main.ml
+++ b/etherlink/bin_node/main.ml
@@ -849,7 +849,9 @@ let make_event_config ~verbosity ~daily_logs_path
   let open Tezos_event_logging.Internal_event in
   let open Tezos_base_unix.Internal_event_unix in
   let open Tezos_base.Internal_event_config in
-  let config = make_with_defaults ~verbosity () in
+  let version = `Log_v1 in
+  let log_cfg = Tezos_base_unix.Logs_simple_config.create_cfg ~version () in
+  let config = make_with_defaults ~log_cfg ~verbosity () in
   let uri =
     make_config_uri
       ~create_dirs:true
@@ -858,6 +860,7 @@ let make_event_config ~verbosity ~daily_logs_path
       ~format:"pp-rfc5424"
       ~chmod:0o640
       ~section_prefixes:daily_logs_section_prefixes
+      ~version
       (`Path Filename.Infix.(daily_logs_path // "daily.log"))
   in
   add_uri_to_config uri config

An example of EVM node invocation

make octez-evm-node
./octez-evm-node run observer --network testnet --dont-track-rollup-node --data-dir foobar --init-from-snapshot

(note: this will download a snapshot of ~34GBytes but you can safely C-c it in the middle of the download)

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Thomas Letan

Merge request reports

Loading