From 9f5ca3de7ed7b3cea237e335f30711120b6526bd Mon Sep 17 00:00:00 2001 From: Age Manning Date: Wed, 17 May 2023 15:24:06 +1000 Subject: [PATCH] Enable SSE logs only on GUI flag and misc reviewers comments --- beacon_node/http_api/src/lib.rs | 4 ++-- beacon_node/src/cli.rs | 4 ++-- book/src/api-lighthouse.md | 5 ++--- book/src/api-vc-endpoints.md | 6 +++--- common/logging/src/sse_logging_components.rs | 4 ++-- lighthouse/src/main.rs | 2 +- validator_client/src/http_api/mod.rs | 4 ++-- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 80712763a7c..3feecfb4157 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -3750,7 +3750,7 @@ pub fn serve( } } Err(e) => Err(warp_utils::reject::server_sent_event_error( - format!("Unable to serialize to JSON {}", e), + format!("Unable to receive event {}", e), )), } }); @@ -3929,4 +3929,4 @@ fn publish_network_message( e )) }) -} +} \ No newline at end of file diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index 633cbf0438d..355a55ecb16 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -1081,7 +1081,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { .long("gui") .hidden(true) .help("Enable the graphical user interface and all its requirements. \ - This is equivalent to --http and --validator-monitor-auto.") + This enables --http and --validator-monitor-auto and enables SSE logging.") .takes_value(false) ) .arg( @@ -1093,4 +1093,4 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { // always using the builder. .conflicts_with("builder-profit-threshold") ) -} +} \ No newline at end of file diff --git a/book/src/api-lighthouse.md b/book/src/api-lighthouse.md index de88c878f6a..47fe62f50b0 100644 --- a/book/src/api-lighthouse.md +++ b/book/src/api-lighthouse.md @@ -684,7 +684,7 @@ Caveats: This is a Server Side Event subscription endpoint. This allows a user to read the Lighthouse logs directly from the HTTP API endpoint. This currently -exposes INFO and higher level logs. +exposes INFO and higher level logs. It is only enabled when the `--gui` flag is set in the CLI. Example: @@ -694,7 +694,7 @@ curl -N "http://localhost:5052/lighthouse/logs" Should provide an output that emits log events as they occur: ```json -{ +{ "data": { "time": "Mar 13 15:28:41", "level": "INFO", @@ -707,4 +707,3 @@ Should provide an output that emits log events as they occur: } } ``` - diff --git a/book/src/api-vc-endpoints.md b/book/src/api-vc-endpoints.md index 7abceee519e..d5d76e4ef43 100644 --- a/book/src/api-vc-endpoints.md +++ b/book/src/api-vc-endpoints.md @@ -588,9 +588,9 @@ logs emitted are INFO level or higher. | Property | Specification | |-------------------|--------------------------------------------| -| Path | `/lighthouse/logs` | +| Path | `/lighthouse/logs` | | Method | GET | -| Required Headers | [`Authorization`](./api-vc-auth-header.md) | +| Required Headers | None | | Typical Responses | 200 | ### Example Response Body @@ -607,4 +607,4 @@ logs emitted are INFO level or higher. "total": 1 } } -``` +``` \ No newline at end of file diff --git a/common/logging/src/sse_logging_components.rs b/common/logging/src/sse_logging_components.rs index 9afec564c99..5cc2bff97de 100644 --- a/common/logging/src/sse_logging_components.rs +++ b/common/logging/src/sse_logging_components.rs @@ -35,7 +35,7 @@ impl Drain for SSELoggingComponents { fn log(&self, record: &Record, logger_values: &OwnedKVList) -> Result { if record.level().is_at_least(LOG_LEVEL) { - // There are subscribers, attempt to send the logs + // Attempt to send the logs match self.sender.send(AsyncRecord::from(record, logger_values)) { Ok(_num_sent) => {} // Everything got sent Err(_err) => {} // There are no subscribers, do nothing @@ -43,4 +43,4 @@ impl Drain for SSELoggingComponents { } Ok(()) } -} +} \ No newline at end of file diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index 2569286bbf6..b814639ceb0 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -485,7 +485,7 @@ fn run( let sse_logging = { if let Some(bn_matches) = matches.subcommand_matches("beacon_node") { - bn_matches.is_present("http") || bn_matches.is_present("gui") + bn_matches.is_present("gui") } else if let Some(vc_matches) = matches.subcommand_matches("validator_client") { vc_matches.is_present("http") } else { diff --git a/validator_client/src/http_api/mod.rs b/validator_client/src/http_api/mod.rs index b5bc87a585c..0c158ce3519 100644 --- a/validator_client/src/http_api/mod.rs +++ b/validator_client/src/http_api/mod.rs @@ -1058,7 +1058,7 @@ pub fn serve( } } Err(e) => Err(warp_utils::reject::server_sent_event_error( - format!("Unable to serialize to JSON {}", e), + format!("Unable to receive event {}", e), )), } }); @@ -1174,4 +1174,4 @@ where response }) -} +} \ No newline at end of file