-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve logging in the Rust part (#1215)
* `agama-web-server` writes now to the stdout if it is not connected to journald. * `agama-dbus-server` uses [tracing](https://github.com/tokio-rs/tracing). * The stdout logger now includes the file/line. They were already included in the journal logs. ``` 2024-05-15T15:30:42.816878Z WARN agama_server::network::nm::client: agama-server/src/network/nm/client.rs:155: Ignoring network device on path /org/freedesktop/NetworkManager/Devices/1 2024-05-15T15:30:42.845629Z INFO agama_server::web::service: agama-server/src/web/service.rs:91: Serving static files from /usr/share/agama/web_ui 2024-05-15T15:30:42.901972Z INFO agama_web_server: agama-server/src/agama-web-server.rs:253: Starting Agama web server at 0.0.0.0:443 2024-05-15T15:30:42.901993Z INFO agama_web_server: agama-server/src/agama-web-server.rs:253: Starting Agama web server at 0.0.0.0:80 ```
- Loading branch information
Showing
7 changed files
with
47 additions
and
88 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//! Functions to work with logs. | ||
|
||
use anyhow::Context; | ||
use libsystemd::logging; | ||
use tracing_subscriber::prelude::*; | ||
|
||
/// Initializes the logging mechanism. | ||
/// | ||
/// It is based on [Tracing](https://github.com/tokio-rs/tracing), part of the Tokio ecosystem. | ||
pub fn init_logging() -> anyhow::Result<()> { | ||
if logging::connected_to_journal() { | ||
let journald = tracing_journald::layer().context("could not connect to journald")?; | ||
tracing_subscriber::registry().with(journald).init(); | ||
} else { | ||
let subscriber = tracing_subscriber::fmt() | ||
.with_file(true) | ||
.with_line_number(true) | ||
.compact() | ||
.finish(); | ||
tracing::subscriber::set_global_default(subscriber)?; | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
------------------------------------------------------------------- | ||
Wed May 15 15:21:30 UTC 2024 - Imobach Gonzalez Sosa <[email protected]> | ||
|
||
- Improve logging in the D-Bus and web servers | ||
(gh#openSUSE/agama#1215): | ||
- Write to the stdout if they are not connected to | ||
systemd-journald. | ||
- The stdout logger includes the file/line (it was already | ||
included when logging to systemd-journald). | ||
|
||
------------------------------------------------------------------- | ||
Wed May 15 14:08:26 UTC 2024 - Imobach Gonzalez Sosa <[email protected]> | ||
|
||
|