Skip to content

chore: Add functionality to convert LogLevel to an OPA log level #798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added

- Add functionality to convert LogLevel to an OPA log level ([#798]).

[#798]: https://github.com/stackabletech/operator-rs/pull/798

## [0.68.0] - 2024-05-22

- Support specifying externalTrafficPolicy in Services created by listener-operator ([#773], [#789], [#791]).
Expand Down
15 changes: 15 additions & 0 deletions crates/stackable-operator/src/product_logging/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,21 @@ impl LogLevel {
self.to_log4j_literal()
}

/// Convert the log level to a string understood by OPA
// based on https://www.openpolicyagent.org/docs/latest/cli/#options-10 opa has only log levels {debug,info,error}
pub fn to_opa_literal(&self) -> String {
match self {
LogLevel::TRACE => "debug",
LogLevel::DEBUG => "debug",
LogLevel::INFO => "info",
LogLevel::WARN => "error",
LogLevel::ERROR => "error",
LogLevel::FATAL => "error",
LogLevel::NONE => "error",
}
.into()
}

/// Convert the log level to a Python expression
pub fn to_python_expression(&self) -> String {
match self {
Expand Down
Loading