Skip to content

Commit 4127d8d

Browse files
xeniapeTechassi
andauthored
chore: Add functionality to convert LogLevel to an OPA log level (#798)
* add to_opa_literal function * add changelog * add changelog headline * Update crates/stackable-operator/CHANGELOG.md Co-authored-by: Techassi <[email protected]> --------- Co-authored-by: Techassi <[email protected]>
1 parent f2f1b6b commit 4127d8d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

crates/stackable-operator/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- Add functionality to convert LogLevel to an OPA log level ([#798]).
10+
11+
[#798]: https://github.com/stackabletech/operator-rs/pull/798
12+
713
## [0.68.0] - 2024-05-22
814

915
- Support specifying externalTrafficPolicy in Services created by listener-operator ([#773], [#789], [#791]).

crates/stackable-operator/src/product_logging/spec.rs

+15
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,21 @@ impl LogLevel {
377377
self.to_log4j_literal()
378378
}
379379

380+
/// Convert the log level to a string understood by OPA
381+
// based on https://www.openpolicyagent.org/docs/latest/cli/#options-10 opa has only log levels {debug,info,error}
382+
pub fn to_opa_literal(&self) -> String {
383+
match self {
384+
LogLevel::TRACE => "debug",
385+
LogLevel::DEBUG => "debug",
386+
LogLevel::INFO => "info",
387+
LogLevel::WARN => "error",
388+
LogLevel::ERROR => "error",
389+
LogLevel::FATAL => "error",
390+
LogLevel::NONE => "error",
391+
}
392+
.into()
393+
}
394+
380395
/// Convert the log level to a Python expression
381396
pub fn to_python_expression(&self) -> String {
382397
match self {

0 commit comments

Comments
 (0)