Skip to content

Commit 3ce83ea

Browse files
committed
Merge branch 'only-disable-timestamps-for-stdout-des-2838'
2 parents f6eef88 + f9c9677 commit 3ce83ea

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

mullvad-daemon/src/logging.rs

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ impl LogHandle {
138138
///
139139
/// * log_level: Base log level, used if `RUST_LOG` is not set.
140140
/// * log_location: Path to the log file, see [`LogLocation`].
141-
/// * output_timestamp: Whether timestamps should be included in the log output.
141+
/// * std_output_timestamp: Whether timestamps should be included in the stdout log output.
142142
pub fn init_logger(
143143
log_level: log::LevelFilter,
144144
log_location: Option<LogLocation>,
145-
output_timestamp: bool,
145+
std_output_timestamp: bool,
146146
) -> Result<LogHandle, Error> {
147147
let level_filter = match log_level {
148148
log::LevelFilter::Off => LevelFilter::OFF,
@@ -192,19 +192,16 @@ pub fn init_logger(
192192
reg.with(android_layer)
193193
};
194194

195-
if output_timestamp {
196-
let file_formatter = tracing_subscriber::fmt::layer()
197-
.with_ansi(false)
198-
.with_writer(non_blocking_file_appender);
199-
let grpc_formatter = tracing_subscriber::fmt::layer()
200-
.with_ansi(true)
201-
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
202-
.with_writer(std::sync::Mutex::new(log_stream));
203-
reg.with(
204-
stdout_formatter.with_timer(tracing_subscriber::fmt::time::ChronoUtc::new(
205-
DATE_TIME_FORMAT_STR.to_string(),
206-
)),
207-
)
195+
let grpc_formatter = tracing_subscriber::fmt::layer()
196+
.with_ansi(true)
197+
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
198+
.with_writer(std::sync::Mutex::new(log_stream));
199+
200+
let file_formatter = tracing_subscriber::fmt::layer()
201+
.with_ansi(false)
202+
.with_writer(non_blocking_file_appender);
203+
204+
let reg = reg
208205
.with(
209206
grpc_formatter.with_timer(tracing_subscriber::fmt::time::ChronoUtc::new(
210207
DATE_TIME_FORMAT_STR.to_string(),
@@ -214,20 +211,16 @@ pub fn init_logger(
214211
file_formatter.with_timer(tracing_subscriber::fmt::time::ChronoUtc::new(
215212
DATE_TIME_FORMAT_STR.to_string(),
216213
)),
214+
);
215+
if std_output_timestamp {
216+
reg.with(
217+
stdout_formatter.with_timer(tracing_subscriber::fmt::time::ChronoUtc::new(
218+
DATE_TIME_FORMAT_STR.to_string(),
219+
)),
217220
)
218221
.init();
219222
} else {
220-
let grpc_formatter = tracing_subscriber::fmt::layer()
221-
.with_ansi(true)
222-
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
223-
.with_writer(std::sync::Mutex::new(log_stream));
224-
let file_formatter = tracing_subscriber::fmt::layer()
225-
.with_ansi(false)
226-
.with_writer(non_blocking_file_appender);
227-
reg.with(stdout_formatter.without_time())
228-
.with(file_formatter.without_time())
229-
.with(grpc_formatter.without_time())
230-
.init();
223+
reg.with(stdout_formatter.without_time()).init();
231224
}
232225

233226
LOG_ENABLED.store(true, Ordering::SeqCst);

0 commit comments

Comments
 (0)