Add option to redirect logging to stderr. (resolves #154)

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-09-23 02:15:05 +00:00
parent 89a67af607
commit 5467c9e486
3 changed files with 18 additions and 2 deletions

View File

@@ -888,6 +888,15 @@ pub struct Config {
#[serde(default)] #[serde(default)]
pub log_thread_ids: bool, pub log_thread_ids: bool,
/// Redirects logging to standard error (stderr). The default is false for
/// stdout. For those using our systemd features the redirection to stderr
/// occurs as necessary and setting this option should not be required. We
/// offer this option for all other users who desire such redirection.
///
/// default: false
#[serde(default)]
pub log_to_stderr: bool,
/// OpenID token expiration/TTL in seconds. /// OpenID token expiration/TTL in seconds.
/// ///
/// These are the OpenID tokens that are primarily used for Matrix account /// These are the OpenID tokens that are primarily used for Matrix account

View File

@@ -28,13 +28,13 @@ pub struct ConsoleWriter {
impl ConsoleWriter { impl ConsoleWriter {
#[must_use] #[must_use]
pub fn new(_config: &Config) -> Self { pub fn new(config: &Config) -> Self {
let journal_stream = get_journal_stream(); let journal_stream = get_journal_stream();
Self { Self {
stdout: io::stdout(), stdout: io::stdout(),
stderr: io::stderr(), stderr: io::stderr(),
_journal_stream: journal_stream.into(), _journal_stream: journal_stream.into(),
use_stderr: journal_stream.0 != 0, use_stderr: journal_stream.0 != 0 || config.log_to_stderr,
} }
} }
} }

View File

@@ -733,6 +733,13 @@
# #
#log_thread_ids = false #log_thread_ids = false
# Redirects logging to standard error (stderr). The default is false for
# stdout. For those using our systemd features the redirection to stderr
# occurs as necessary and setting this option should not be required. We
# offer this option for all other users who desire such redirection.
#
#log_to_stderr = false
# OpenID token expiration/TTL in seconds. # OpenID token expiration/TTL in seconds.
# #
# These are the OpenID tokens that are primarily used for Matrix account # These are the OpenID tokens that are primarily used for Matrix account