mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-22 14:24:44 +00:00
Log to file without json format (#1485)
## Issue Addressed N/A ## Proposed Changes Earlier, to log to a file, the only options were to redirect stdout/stderr to a file or use json logging. Redirecting to stdout/stderr works well but causes issues with mistakenly overwriting the file instead of appending which has resulted in loss of precious logs on multiple occasions for me. Json logging creates a timestamped backup of the file if it already exists, but the json format itself is hugely annoying. This PR modifies the `--logfile` option to log as it does in the terminal to a logfile.
This commit is contained in:
@@ -4,6 +4,7 @@ extern crate lazy_static;
|
||||
use lighthouse_metrics::{
|
||||
inc_counter, try_create_int_counter, IntCounter, Result as MetricsResult,
|
||||
};
|
||||
use slog_term::Decorator;
|
||||
use std::io::{Result, Write};
|
||||
|
||||
pub const MAX_MESSAGE_WIDTH: usize = 40;
|
||||
@@ -19,13 +20,13 @@ lazy_static! {
|
||||
try_create_int_counter("crit_total", "Count of crits logged");
|
||||
}
|
||||
|
||||
pub struct AlignedTermDecorator {
|
||||
wrapped: slog_term::TermDecorator,
|
||||
pub struct AlignedTermDecorator<D: Decorator> {
|
||||
wrapped: D,
|
||||
message_width: usize,
|
||||
}
|
||||
|
||||
impl AlignedTermDecorator {
|
||||
pub fn new(decorator: slog_term::TermDecorator, message_width: usize) -> AlignedTermDecorator {
|
||||
impl<D: Decorator> AlignedTermDecorator<D> {
|
||||
pub fn new(decorator: D, message_width: usize) -> Self {
|
||||
AlignedTermDecorator {
|
||||
wrapped: decorator,
|
||||
message_width,
|
||||
@@ -33,7 +34,7 @@ impl AlignedTermDecorator {
|
||||
}
|
||||
}
|
||||
|
||||
impl slog_term::Decorator for AlignedTermDecorator {
|
||||
impl<D: Decorator> Decorator for AlignedTermDecorator<D> {
|
||||
fn with_record<F>(
|
||||
&self,
|
||||
record: &slog::Record,
|
||||
|
||||
Reference in New Issue
Block a user