Compare commits
2 commits
3428c31f16
...
6d40fbee47
Author | SHA1 | Date | |
---|---|---|---|
asonix | 6d40fbee47 | ||
asonix | c4e99ef539 |
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1804,7 +1804,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pict-rs"
|
||||
version = "0.5.12"
|
||||
version = "0.5.13"
|
||||
dependencies = [
|
||||
"actix-form-data",
|
||||
"actix-web",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "pict-rs"
|
||||
description = "A simple image hosting service"
|
||||
version = "0.5.12"
|
||||
version = "0.5.13"
|
||||
authors = ["asonix <asonix@asonix.dog>"]
|
||||
license = "AGPL-3.0"
|
||||
readme = "README.md"
|
||||
|
|
|
@ -16,6 +16,7 @@ concurrency = 32
|
|||
format = "normal"
|
||||
targets = "info"
|
||||
log_spans = false
|
||||
no_ansi = false
|
||||
|
||||
[tracing.console]
|
||||
buffer_capacity = 102400
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "pict-rs";
|
||||
version = "0.5.12";
|
||||
version = "0.5.13";
|
||||
src = ./.;
|
||||
|
||||
cargoLock = {
|
||||
|
|
|
@ -98,6 +98,11 @@ targets = 'info'
|
|||
# default: false
|
||||
log_spans = false
|
||||
|
||||
## Optional: whether to disable colorized log output
|
||||
# environment variable: PICTRS__TRACING__LOGGING__NO_ANSI
|
||||
# default: false
|
||||
no_ansi = false
|
||||
|
||||
|
||||
## Console configuration
|
||||
[tracing.console]
|
||||
|
|
62
releases/0.5.13.md
Normal file
62
releases/0.5.13.md
Normal file
|
@ -0,0 +1,62 @@
|
|||
# pict-rs 0.5.13
|
||||
|
||||
pict-rs is a simple image hosting microservice, designed to handle storing and retrieving images,
|
||||
animations, and videos, as well as providing basic image processing functionality.
|
||||
|
||||
## Overview
|
||||
|
||||
pict-rs 0.5.13 is a maintenance release aiming to enable better logging in some scenarios.
|
||||
|
||||
### Features
|
||||
|
||||
- [Colorless Logging](#colorless-logging)
|
||||
|
||||
|
||||
### Changes
|
||||
|
||||
- [Remove Flume](#remove-flume)
|
||||
|
||||
|
||||
## Upgrade Notes
|
||||
|
||||
There are no significant changes from 0.5.12. Upgrading should be as simple as pulling a new version
|
||||
of pict-rs.
|
||||
|
||||
|
||||
## Descriptions
|
||||
|
||||
### Colorless Logging
|
||||
|
||||
When opting to use the `json` logger, the tracing subscriber automatically disables colored output.
|
||||
This didn't remove colors from errors, though, and pict-rs hasn't had a way to disable colors while
|
||||
using other log formats. pict-rs 0.5.13 introduces a new configuration value to remove colored
|
||||
output from all logs regardless of logging format.
|
||||
|
||||
With pict-rs.toml
|
||||
```toml
|
||||
[tracing.logging]
|
||||
no_ansi = true
|
||||
```
|
||||
|
||||
With environment variables
|
||||
```bash
|
||||
PICTRS__TRACING__LOGGING__NO_ANSI=true pict-rs run
|
||||
```
|
||||
|
||||
With commandline flags
|
||||
```bash
|
||||
pict-rs --no-log-ansi run
|
||||
```
|
||||
|
||||
Colors in logs can be useful, so I imagine this option won't be used much. There has been a request
|
||||
for this functionality though and it's little cost to maintain.
|
||||
|
||||
|
||||
### Remove Flume
|
||||
|
||||
Recently I've been debugging a memory usage issue in another project of mine. I wasn't able to fully
|
||||
track down the cause, but I did notice that removing the
|
||||
[flume channel library](https://github.com/zesterer/flume) seemed to make the leak go away. Since I
|
||||
also use flume in pict-rs, I'm opting to replace it with tokio's native channel implementation. This
|
||||
may or may not improve memory usage, but it does reduce the depenency count and therefore build time
|
||||
for pict-rs.
|
|
@ -18,6 +18,7 @@ impl Args {
|
|||
log_format,
|
||||
log_targets,
|
||||
log_spans,
|
||||
no_log_ansi,
|
||||
console_address,
|
||||
console_buffer_capacity,
|
||||
opentelemetry_url,
|
||||
|
@ -38,6 +39,7 @@ impl Args {
|
|||
format: log_format,
|
||||
targets: log_targets.map(Serde::new),
|
||||
log_spans,
|
||||
no_ansi: no_log_ansi,
|
||||
},
|
||||
console: Console {
|
||||
address: console_address,
|
||||
|
@ -581,6 +583,8 @@ struct Logging {
|
|||
targets: Option<Serde<Targets>>,
|
||||
#[serde(skip_serializing_if = "std::ops::Not::not")]
|
||||
log_spans: bool,
|
||||
#[serde(skip_serializing_if = "std::ops::Not::not")]
|
||||
no_ansi: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, serde::Serialize)]
|
||||
|
@ -925,6 +929,10 @@ pub(super) struct Args {
|
|||
#[arg(long)]
|
||||
log_spans: bool,
|
||||
|
||||
#[arg(long)]
|
||||
/// Whether to disable color-codes in log output
|
||||
no_log_ansi: bool,
|
||||
|
||||
/// Address and port to expose tokio-console metrics
|
||||
#[arg(long)]
|
||||
console_address: Option<SocketAddr>,
|
||||
|
|
|
@ -55,6 +55,7 @@ struct LoggingDefaults {
|
|||
format: LogFormat,
|
||||
targets: Serde<Targets>,
|
||||
log_spans: bool,
|
||||
no_ansi: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize)]
|
||||
|
@ -235,6 +236,7 @@ impl Default for LoggingDefaults {
|
|||
format: LogFormat::Normal,
|
||||
targets: "info".parse().expect("Valid targets string"),
|
||||
log_spans: false,
|
||||
no_ansi: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,6 +163,8 @@ pub(crate) struct Logging {
|
|||
pub(crate) targets: Serde<Targets>,
|
||||
|
||||
pub(crate) log_spans: bool,
|
||||
|
||||
pub(crate) no_ansi: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::config::{LogFormat, OpenTelemetry, Tracing};
|
||||
use color_eyre::config::Theme;
|
||||
use console_subscriber::ConsoleLayer;
|
||||
use opentelemetry::KeyValue;
|
||||
use opentelemetry_otlp::WithExportConfig;
|
||||
|
@ -11,7 +12,15 @@ use tracing_subscriber::{
|
|||
};
|
||||
|
||||
pub(super) fn init_tracing(tracing: &Tracing) -> color_eyre::Result<()> {
|
||||
color_eyre::install()?;
|
||||
let eyre_theme = if tracing.logging.no_ansi {
|
||||
Theme::new()
|
||||
} else {
|
||||
Theme::dark()
|
||||
};
|
||||
|
||||
color_eyre::config::HookBuilder::new()
|
||||
.theme(eyre_theme)
|
||||
.install()?;
|
||||
|
||||
LogTracer::init()?;
|
||||
|
||||
|
@ -23,7 +32,9 @@ pub(super) fn init_tracing(tracing: &Tracing) -> color_eyre::Result<()> {
|
|||
FmtSpan::NONE
|
||||
};
|
||||
|
||||
let format_layer = tracing_subscriber::fmt::layer().with_span_events(fmt_span);
|
||||
let format_layer = tracing_subscriber::fmt::layer()
|
||||
.with_span_events(fmt_span)
|
||||
.with_ansi(!tracing.logging.no_ansi);
|
||||
|
||||
match tracing.logging.format {
|
||||
LogFormat::Compact => with_format(format_layer.compact(), tracing),
|
||||
|
|
Loading…
Reference in a new issue