Skip to content

Commit

Permalink
profiles renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
pamburus committed Jun 26, 2024
1 parent f55f4ce commit fdc01c8
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 88 deletions.
32 changes: 28 additions & 4 deletions etc/defaults/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,54 @@ fields:

# Formatting settings.
formatting:
# Whether to flatten nested objects [never|auto|always].
flatten: always
expansion:
mode: moderately
# Field expansion mode [never|inline|low|medium|high|always].
mode: medium
# Field expansion setting profiles for all modes except [never,inline,always].
profiles:
slightly:
# Field expansion settings for the low mode.
low:
# Multiline field expansion mode [standard|disabled|inline].
multiline: standard
# Various complexity thresholds for field expansion.
thresholds:
# Threshold of overall draft log record complexity that triggers expansion of all fields.
global: 2048
# Threshold of cumulative complexity of all fields on the first line that triggers expansion of remaining fields.
cumulative: 512
# Threshold of message field's complexity that triggers its expansion.
message: 256
# Threshold of any other field's complexity that triggers its expansion.
field: 128
moderately:
# Field expansion settings for the medium mode.
medium:
# Multiline field expansion mode [standard|disabled|inline].
multiline: standard
# Various complexity thresholds for field expansion.
thresholds:
# Threshold of overall draft log record complexity that triggers expansion of all fields.
global: 1024
# Threshold of cumulative complexity of all fields on the first line that triggers expansion of remaining fields.
cumulative: 256
# Threshold of message field's complexity that triggers its expansion.
message: 192
# Threshold of any other field's complexity that triggers its expansion.
field: 64
extensively:
# Field expansion settings for the high mode.
high:
# Multiline field expansion mode [standard|disabled|inline].
multiline: standard
# Various complexity thresholds for field expansion.
thresholds:
# Threshold of overall draft log record complexity that triggers expansion of all fields.
global: 768
# Threshold of cumulative complexity of all fields on the first line that triggers expansion of remaining fields.
cumulative: 192
# Threshold of message field's complexity that triggers its expansion.
message: 128
# Threshold of any other field's complexity that triggers its expansion.
field: 48
punctuation:
logger-name-separator: ':'
Expand Down
12 changes: 6 additions & 6 deletions schema/json/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,23 +297,23 @@
"enum": [
"never",
"inline",
"slightly",
"moderately",
"extensively",
"low",
"medium",
"high",
"always"
]
},
"expansion-profiles": {
"type": "object",
"additionalProperties": false,
"properties": {
"slightly": {
"low": {
"$ref": "#/definitions/expansion-profile"
},
"moderately": {
"medium": {
"$ref": "#/definitions/expansion-profile"
},
"extensively": {
"high": {
"$ref": "#/definitions/expansion-profile"
}
}
Expand Down
71 changes: 37 additions & 34 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,15 @@ pub struct Opt {
#[arg(
long,
short = 'x',
env = "HL_EXPAND",
value_name = "WHEN",
env = "HL_EXPANSION",
value_name = "MODE",
value_enum,
default_value_t = config::global::get().formatting.expansion.mode.into(),
overrides_with = "expand",
overrides_with = "expansion",
default_missing_value = "always",
help_heading = heading::OUTPUT,
)]
pub expand: ExpandOption,
pub expansion: ExpansionOption,

Check warning on line 305 in src/cli.rs

View check run for this annotation

Codecov / codecov/patch

src/cli.rs#L305

Added line #L305 was not covered by tests

/// Show input number and/or input filename before each message.
#[arg(
Expand Down Expand Up @@ -500,43 +500,43 @@ impl Into<settings::FlattenOption> for FlattenOption {
}

#[derive(ValueEnum, Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ExpandOption {
pub enum ExpansionOption {
Never,
Inline,
Slightly,
Low,
#[default]
Moderately,
Extensively,
Medium,
High,
Always,
}

impl From<settings::ExpansionMode> for ExpandOption {
impl From<settings::ExpansionMode> for ExpansionOption {
fn from(value: settings::ExpansionMode) -> Self {
match value {
settings::ExpansionMode::Never => Self::Never,
settings::ExpansionMode::Inline => Self::Inline,
settings::ExpansionMode::Slightly => Self::Slightly,
settings::ExpansionMode::Moderately => Self::Moderately,
settings::ExpansionMode::Extensively => Self::Extensively,
settings::ExpansionMode::Low => Self::Low,

Check warning on line 518 in src/cli.rs

View check run for this annotation

Codecov / codecov/patch

src/cli.rs#L517-L518

Added lines #L517 - L518 were not covered by tests
settings::ExpansionMode::Medium => Self::Medium,
settings::ExpansionMode::High => Self::High,

Check warning on line 520 in src/cli.rs

View check run for this annotation

Codecov / codecov/patch

src/cli.rs#L520

Added line #L520 was not covered by tests
settings::ExpansionMode::Always => Self::Always,
}
}
}

impl From<Option<settings::ExpansionMode>> for ExpandOption {
impl From<Option<settings::ExpansionMode>> for ExpansionOption {
fn from(value: Option<settings::ExpansionMode>) -> Self {
Self::from(value.unwrap_or_default())
}
}

impl Into<settings::ExpansionMode> for ExpandOption {
impl Into<settings::ExpansionMode> for ExpansionOption {
fn into(self) -> settings::ExpansionMode {
match self {
Self::Never => settings::ExpansionMode::Never,
Self::Inline => settings::ExpansionMode::Inline,
Self::Slightly => settings::ExpansionMode::Slightly,
Self::Moderately => settings::ExpansionMode::Moderately,
Self::Extensively => settings::ExpansionMode::Extensively,
Self::Low => settings::ExpansionMode::Low,

Check warning on line 537 in src/cli.rs

View check run for this annotation

Codecov / codecov/patch

src/cli.rs#L536-L537

Added lines #L536 - L537 were not covered by tests
Self::Medium => settings::ExpansionMode::Medium,
Self::High => settings::ExpansionMode::High,

Check warning on line 539 in src/cli.rs

View check run for this annotation

Codecov / codecov/patch

src/cli.rs#L539

Added line #L539 was not covered by tests
Self::Always => settings::ExpansionMode::Always,
}
}
Expand Down Expand Up @@ -603,39 +603,42 @@ mod tests {
}

#[test]
fn test_expand_option() {
assert_eq!(ExpandOption::from(None), ExpandOption::Moderately);
fn test_expansion_option() {
assert_eq!(ExpansionOption::from(None), ExpansionOption::Medium);
assert_eq!(
ExpansionOption::from(Some(settings::ExpansionMode::Medium)),
ExpansionOption::Medium
);
assert_eq!(
ExpandOption::from(Some(settings::ExpansionMode::Moderately)),
ExpandOption::Moderately
ExpansionOption::from(Some(settings::ExpansionMode::Never)),
ExpansionOption::Never
);
assert_eq!(
ExpandOption::from(Some(settings::ExpansionMode::Never)),
ExpandOption::Never
ExpansionOption::from(Some(settings::ExpansionMode::Always)),
ExpansionOption::Always
);
assert_eq!(
ExpandOption::from(Some(settings::ExpansionMode::Always)),
ExpandOption::Always
ExpansionOption::from(settings::ExpansionMode::Medium),
ExpansionOption::Medium
);
assert_eq!(
ExpandOption::from(settings::ExpansionMode::Moderately),
ExpandOption::Moderately
ExpansionOption::from(settings::ExpansionMode::Never),
ExpansionOption::Never
);
assert_eq!(ExpandOption::from(settings::ExpansionMode::Never), ExpandOption::Never);
assert_eq!(
ExpandOption::from(settings::ExpansionMode::Always),
ExpandOption::Always
ExpansionOption::from(settings::ExpansionMode::Always),
ExpansionOption::Always
);
assert_eq!(
Into::<settings::ExpansionMode>::into(ExpandOption::Moderately),
settings::ExpansionMode::Moderately
Into::<settings::ExpansionMode>::into(ExpansionOption::Medium),
settings::ExpansionMode::Medium
);
assert_eq!(
Into::<settings::ExpansionMode>::into(ExpandOption::Never),
Into::<settings::ExpansionMode>::into(ExpansionOption::Never),
settings::ExpansionMode::Never
);
assert_eq!(
Into::<settings::ExpansionMode>::into(ExpandOption::Always),
Into::<settings::ExpansionMode>::into(ExpansionOption::Always),
settings::ExpansionMode::Always
);
}
Expand Down
Loading

0 comments on commit fdc01c8

Please sign in to comment.