mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-01-27 14:43:19 -05:00
support color coding logs (#112)
ffmpeg was already doing this; now do it for native logs.
This commit is contained in:
parent
242368aa47
commit
ea8bdef7d9
@ -45,11 +45,14 @@ Logging options are controlled by environment variables:
|
|||||||
accepted are `google` (the default, like the Google
|
accepted are `google` (the default, like the Google
|
||||||
[glog](https://github.com/google/glog) package) and `google-systemd` (a
|
[glog](https://github.com/google/glog) package) and `google-systemd` (a
|
||||||
variation for better systemd compatibility).
|
variation for better systemd compatibility).
|
||||||
|
* `MOONFIRE_COLOR` controls color coding when using the `google` format.
|
||||||
|
It accepts `on`, `off`, or `auto`. `auto` means to color code if stderr
|
||||||
|
is a terminal.
|
||||||
* Errors include a backtrace if `RUST_BACKTRACE=1` is set.
|
* Errors include a backtrace if `RUST_BACKTRACE=1` is set.
|
||||||
|
|
||||||
If you use Docker, set these via Docker's `--env` argument.
|
If you use Docker, set these via Docker's `--env` argument.
|
||||||
|
|
||||||
With the default `MOONFIRE_FORMAT=glog`, log lines are in the following
|
With the default `MOONFIRE_FORMAT=google`, log lines are in the following
|
||||||
format:
|
format:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
3
server/Cargo.lock
generated
3
server/Cargo.lock
generated
@ -1274,9 +1274,10 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "mylog"
|
name = "mylog"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/scottlamb/mylog#64519c6d9d4587d803900b82a83b45b35939b8f7"
|
source = "git+https://github.com/scottlamb/mylog#1406a8d794d799971e0e1079d5188d2dc339c584"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
]
|
]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// This file is part of Moonfire NVR, a security camera network video recorder.
|
// This file is part of Moonfire NVR, a security camera network video recorder.
|
||||||
// Copyright (C) 2020 The Moonfire NVR Authors; see AUTHORS and LICENSE.txt.
|
// Copyright (C) 2021 The Moonfire NVR Authors; see AUTHORS and LICENSE.txt.
|
||||||
// SPDX-License-Identifier: GPL-v3.0-or-later WITH GPL-3.0-linking-exception.
|
// SPDX-License-Identifier: GPL-v3.0-or-later WITH GPL-3.0-linking-exception.
|
||||||
|
|
||||||
#![cfg_attr(all(feature = "nightly", test), feature(test))]
|
#![cfg_attr(all(feature = "nightly", test), feature(test))]
|
||||||
@ -116,6 +116,12 @@ fn main() {
|
|||||||
.and_then(|s| mylog::Format::from_str(&s))
|
.and_then(|s| mylog::Format::from_str(&s))
|
||||||
.unwrap_or(mylog::Format::Google),
|
.unwrap_or(mylog::Format::Google),
|
||||||
)
|
)
|
||||||
|
.set_color(
|
||||||
|
::std::env::var("MOONFIRE_COLOR")
|
||||||
|
.map_err(|_| ())
|
||||||
|
.and_then(|s| mylog::ColorMode::from_str(&s))
|
||||||
|
.unwrap_or(mylog::ColorMode::Auto),
|
||||||
|
)
|
||||||
.set_spec(&::std::env::var("MOONFIRE_LOG").unwrap_or("info".to_owned()))
|
.set_spec(&::std::env::var("MOONFIRE_LOG").unwrap_or("info".to_owned()))
|
||||||
.build();
|
.build();
|
||||||
h.clone().install().unwrap();
|
h.clone().install().unwrap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user