Skip to content

Commit

Permalink
rename log_access_* variables to access_logs_*
Browse files Browse the repository at this point in the history
apply clippy suggestions
  • Loading branch information
Keksoj committed Feb 14, 2024
1 parent 45b0317 commit 367c6d5
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 31 deletions.
4 changes: 2 additions & 2 deletions bin/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ log_target = "stdout"

# optional different target for access logs (IP addresses, domains, URI, HTTP status, etc)
# It supports the same options as log_target
# log_access_target = "file:///var/logs/sozu-access.log"
# access_logs_target = "file:///var/logs/sozu-access.log"

# format of the access logs. Defaults to ascii.
# - ascii
# - protobuf (defined in [sozu_command_lib::proto::command::ProtobufAccessLog])
# log_access_format = "ascii"
# access_logs_format = "ascii"

# path to the unix socket file used to send commands to sozu
# default value points to "sozu.sock" file in the current directory
Expand Down
2 changes: 1 addition & 1 deletion bin/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub fn begin_worker_process(
setup_logging(
&worker_config.log_target,
worker_config.log_colored,
worker_config.log_access_target.as_deref(),
worker_config.access_logs_target.as_deref(),
Some(access_log_format),
Some(worker_config.log_colored),
&worker_config.log_level,
Expand Down
2 changes: 1 addition & 1 deletion command/src/command.proto
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ message ServerConfig {
required uint64 buffer_size = 9 [default = 16393];
required string log_level = 10 [default = "info"];
required string log_target = 11 [default = "stdout"];
optional string log_access_target = 12;
optional string access_logs_target = 12;
required uint64 command_buffer_size = 13 [default = 1000000];
required uint64 max_command_buffer_size = 14 [default = 2000000];
optional ServerMetricsConfig metrics = 15;
Expand Down
26 changes: 13 additions & 13 deletions command/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,11 +1093,11 @@ pub struct FileConfig {
#[serde(default)]
pub log_colored: bool,
#[serde(default)]
pub log_access_target: Option<String>,
pub access_logs_target: Option<String>,
#[serde(default)]
pub log_access_format: Option<AccessLogFormat>,
pub access_logs_format: Option<AccessLogFormat>,
#[serde(default)]
pub log_access_colored: Option<bool>,
pub access_logs_colored: Option<bool>,
pub worker_count: Option<u16>,
pub worker_automatic_restart: Option<bool>,
pub metrics: Option<MetricsConfig>,
Expand Down Expand Up @@ -1208,9 +1208,9 @@ impl ConfigBuilder {
ctl_command_timeout: file_config.ctl_command_timeout.unwrap_or(1_000),
front_timeout: file_config.front_timeout.unwrap_or(DEFAULT_FRONT_TIMEOUT),
handle_process_affinity: file_config.handle_process_affinity.unwrap_or(false),
log_access_target: file_config.log_access_target.clone(),
log_access_format: file_config.log_access_format.clone(),
log_access_colored: file_config.log_access_colored,
access_logs_target: file_config.access_logs_target.clone(),
access_logs_format: file_config.access_logs_format.clone(),
access_logs_colored: file_config.access_logs_colored,
log_level: file_config
.log_level
.clone()
Expand Down Expand Up @@ -1458,9 +1458,9 @@ pub struct Config {
pub log_target: String,
pub log_colored: bool,
#[serde(default)]
pub log_access_target: Option<String>,
pub log_access_format: Option<AccessLogFormat>,
pub log_access_colored: Option<bool>,
pub access_logs_target: Option<String>,
pub access_logs_format: Option<AccessLogFormat>,
pub access_logs_colored: Option<bool>,
pub worker_count: u16,
pub worker_automatic_restart: bool,
pub metrics: Option<MetricsConfig>,
Expand Down Expand Up @@ -1768,8 +1768,8 @@ impl fmt::Debug for Config {
.field("automatic_state_save", &self.automatic_state_save)
.field("log_level", &self.log_level)
.field("log_target", &self.log_target)
.field("log_access_target", &self.log_access_target)
.field("log_access_format", &self.log_access_format)
.field("access_logs_target", &self.access_logs_target)
.field("access_logs_format", &self.access_logs_format)
.field("worker_count", &self.worker_count)
.field("worker_automatic_restart", &self.worker_automatic_restart)
.field("metrics", &self.metrics)
Expand Down Expand Up @@ -1823,11 +1823,11 @@ impl From<&Config> for ServerConfig {
buffer_size: config.buffer_size,
log_level: config.log_level.clone(),
log_target: config.log_target.clone(),
log_access_target: config.log_access_target.clone(),
access_logs_target: config.access_logs_target.clone(),
command_buffer_size: config.command_buffer_size,
max_command_buffer_size: config.max_command_buffer_size,
metrics,
access_log_format: ProtobufAccessLogFormat::from(&config.log_access_format) as i32,
access_log_format: ProtobufAccessLogFormat::from(&config.access_logs_format) as i32,
log_colored: config.log_colored,
}
}
Expand Down
18 changes: 9 additions & 9 deletions command/src/logging/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,9 @@ pub fn setup_logging_with_config(config: &Config, tag: &str) {
setup_logging(
&config.log_target,
config.log_colored,
config.log_access_target.as_deref(),
config.log_access_format.clone(),
config.log_access_colored,
config.access_logs_target.as_deref(),
config.access_logs_format.clone(),
config.access_logs_colored,
&config.log_level,
tag,
)
Expand All @@ -606,23 +606,23 @@ pub fn setup_logging_with_config(config: &Config, tag: &str) {
pub fn setup_logging(
log_target: &str,
log_colored: bool,
log_access_target: Option<&str>,
log_access_format: Option<AccessLogFormat>,
log_access_colored: Option<bool>,
access_logs_target: Option<&str>,
access_logs_format: Option<AccessLogFormat>,
access_logs_colored: Option<bool>,
log_level: &str,
tag: &str,
) {
let backend = target_to_backend(log_target);
let access_backend = log_access_target.map(target_to_backend);
let access_backend = access_logs_target.map(target_to_backend);

Logger::init(
tag.to_string(),
env::var("RUST_LOG").as_deref().unwrap_or(log_level),
backend,
log_colored,
access_backend,
log_access_format,
log_access_colored,
access_logs_format,
access_logs_colored,
);
}

Expand Down
2 changes: 1 addition & 1 deletion doc/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Parameters in the global section allow you to define the global settings shared
| `saved_state` | path from which sozu tries to load its state at startup | |
| `log_level` | possible values are | `debug`, `trace`, `error`, `warn`, `info`|
| `log_target` | possible values are | `stdout, tcp or udp address` |
| `log_access_target` | possible values are (if activated, sends access logs to a separate target) | `stdout`, `tcp` or `udp address` |
| `access_logs_target` | possible values are (if activated, sends access logs to a separate target) | `stdout`, `tcp` or `udp address` |
| `command_socket` | path to the unix socket command | |
| `command_buffer_size` | size, in bytes, of the buffer used by the main process to handle commands. | |
| `max_command_buffer_size` | maximum size of the buffer used by the main process to handle commands. | |
Expand Down
2 changes: 1 addition & 1 deletion doc/debugging_strategies.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ There are three configuration options related to logging:
* `tcp://127.0.0.1:9876`
* `unix:///var/sozu/logs`
* `file:///var/logs/sozu.log`
* `log_access_target`: if activated, sends the access logs to a separate destination
* `access_logs_target`: if activated, sends the access logs to a separate destination

`log_level` follows [env_logger's level directives](https://docs.rs/env_logger/0.5.13/env_logger/).
Moreover, the `RUST_LOG` environment variable can be used to override the log level.
Expand Down
3 changes: 1 addition & 2 deletions lib/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use time::{Duration, Instant};

use sozu_command::{
channel::Channel,
config::Config,
logging,
proto::command::{
request::RequestType, response_content::ContentType, ActivateListener, AddBackend,
Expand Down Expand Up @@ -940,7 +939,7 @@ impl Server {
ContentType::Clusters(ClusterInformations {
vec: self
.config_state
.cluster_state(&cluster_id)
.cluster_state(cluster_id)
.map_or(vec![], |ci| vec![ci]),
})
.into(),
Expand Down
2 changes: 1 addition & 1 deletion os-build/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ log_target = "stdout"

# optional different target for access logs (IP addresses, domains, URI, HTTP status, etc)
# It supports the same options as log_target
# log_access_target = "file:///var/log/sozu-access.log"
# access_logs_target = "file:///var/log/sozu-access.log"

# path to the unix socket file used to send commands to sozu
# default value points to "sozu.sock" file in the current directory
Expand Down

0 comments on commit 367c6d5

Please sign in to comment.