1+ //! Renders the logging config files (`log4j.properties` / `log4j2.properties` and the
2+ //! Vector agent config) assembled into the rolegroup `ConfigMap`.
3+
14use std:: { borrow:: Cow , collections:: BTreeMap , fmt:: Display } ;
25
36use stackable_operator:: {
@@ -9,41 +12,21 @@ use stackable_operator::{
912 role_utils:: RoleGroupRef ,
1013} ;
1114
12- use crate :: crd:: {
13- role:: { AnyConfig , broker:: BrokerContainer , controller:: ControllerContainer } ,
14- v1alpha1,
15+ use crate :: {
16+ controller:: MAX_KAFKA_LOG_FILES_SIZE ,
17+ crd:: {
18+ LOG4J_CONFIG_FILE , LOG4J2_CONFIG_FILE , STACKABLE_LOG_DIR ,
19+ role:: { AnyConfig , broker:: BrokerContainer , controller:: ControllerContainer } ,
20+ v1alpha1,
21+ } ,
1522} ;
1623
17- pub const BROKER_ID_POD_MAP_DIR : & str = "/stackable/broker-id-pod-map" ;
18- pub const STACKABLE_LOG_CONFIG_DIR : & str = "/stackable/log_config" ;
19- pub const STACKABLE_LOG_DIR : & str = "/stackable/log" ;
20- // log4j
21- const LOG4J_CONFIG_FILE : & str = "log4j.properties" ;
2224const KAFKA_LOG4J_FILE : & str = "kafka.log4j.xml" ;
23- // log4j2
24- const LOG4J2_CONFIG_FILE : & str = "log4j2.properties" ;
2525const KAFKA_LOG4J2_FILE : & str = "kafka.log4j2.xml" ;
26- // max size
27- pub const MAX_KAFKA_LOG_FILES_SIZE : MemoryQuantity = MemoryQuantity {
28- value : 10.0 ,
29- unit : BinaryMultiple :: Mebi ,
30- } ;
3126
3227const CONSOLE_CONVERSION_PATTERN_LOG4J : & str = "[%d] %p %m (%c)%n" ;
3328const CONSOLE_CONVERSION_PATTERN_LOG4J2 : & str = "%d{ISO8601} %p [%t] %c - %m%n" ;
3429
35- pub fn kafka_log_opts ( product_version : & str ) -> String {
36- if product_version. starts_with ( "3." ) {
37- format ! ( "-Dlog4j.configuration=file:{STACKABLE_LOG_CONFIG_DIR}/{LOG4J_CONFIG_FILE}" )
38- } else {
39- format ! ( "-Dlog4j2.configurationFile=file:{STACKABLE_LOG_CONFIG_DIR}/{LOG4J2_CONFIG_FILE}" )
40- }
41- }
42-
43- pub fn kafka_log_opts_env_var ( ) -> String {
44- "KAFKA_LOG4J_OPTS" . to_string ( )
45- }
46-
4730/// Get the role group ConfigMap data with logging and Vector configurations
4831pub fn role_group_config_map_data (
4932 product_version : & str ,
0 commit comments