@@ -28,7 +28,7 @@ use tokio::{
28
28
use tracing:: { error, info, warn} ;
29
29
use url:: Url ;
30
30
31
- use crate :: { option :: CONFIG , HTTP_CLIENT } ;
31
+ use crate :: { parseable :: PARSEABLE , HTTP_CLIENT } ;
32
32
33
33
use super :: { AuditLog , AUDIT_LOG_TX } ;
34
34
@@ -48,15 +48,15 @@ impl Default for AuditLogger {
48
48
fn default ( ) -> Self {
49
49
let mut logger = AuditLogger {
50
50
log_endpoint : None ,
51
- batch : Vec :: with_capacity ( CONFIG . options . audit_batch_size ) ,
51
+ batch : Vec :: with_capacity ( PARSEABLE . options . audit_batch_size ) ,
52
52
next_log_file_id : 0 ,
53
53
oldest_log_file_id : 0 ,
54
54
} ;
55
55
56
56
// Try to construct the log endpoint URL by joining the base URL
57
57
// with the ingest path, This can fail if the URL is not valid,
58
58
// when the base URL is not set or the ingest path is not valid
59
- let Some ( url) = CONFIG . options . audit_logger . as_ref ( ) else {
59
+ let Some ( url) = PARSEABLE . options . audit_logger . as_ref ( ) else {
60
60
return logger;
61
61
} ;
62
62
@@ -66,11 +66,11 @@ impl Default for AuditLogger {
66
66
. ok ( ) ;
67
67
68
68
// Created directory for audit logs if it doesn't exist
69
- std:: fs:: create_dir_all ( & CONFIG . options . audit_log_dir )
69
+ std:: fs:: create_dir_all ( & PARSEABLE . options . audit_log_dir )
70
70
. expect ( "Failed to create audit log directory" ) ;
71
71
72
72
// Figure out the latest and oldest log file in directory
73
- let files = std:: fs:: read_dir ( & CONFIG . options . audit_log_dir )
73
+ let files = std:: fs:: read_dir ( & PARSEABLE . options . audit_log_dir )
74
74
. expect ( "Failed to read audit log directory" ) ;
75
75
let ( oldest_log_file_id, latest_log_file_id) =
76
76
files. fold ( ( usize:: MAX , 0 ) , |( oldest, latest) , r| {
@@ -106,7 +106,7 @@ impl AuditLogger {
106
106
}
107
107
108
108
// swap the old batch with a new empty one
109
- let mut logs_to_send = Vec :: with_capacity ( CONFIG . options . audit_batch_size ) ;
109
+ let mut logs_to_send = Vec :: with_capacity ( PARSEABLE . options . audit_batch_size ) ;
110
110
std:: mem:: swap ( & mut self . batch , & mut logs_to_send) ;
111
111
112
112
// send the logs to the remote logging system, if no backlog, else write to disk
@@ -117,7 +117,7 @@ impl AuditLogger {
117
117
}
118
118
119
119
// write the logs to the next log file
120
- let log_file_path = CONFIG
120
+ let log_file_path = PARSEABLE
121
121
. options
122
122
. audit_log_dir
123
123
. join ( format ! ( "{}.json" , self . next_log_file_id) ) ;
@@ -141,7 +141,7 @@ impl AuditLogger {
141
141
self . batch . push ( log) ;
142
142
143
143
// Flush if batch size exceeds threshold
144
- if self . batch . len ( ) >= CONFIG . options . audit_batch_size {
144
+ if self . batch . len ( ) >= PARSEABLE . options . audit_batch_size {
145
145
self . flush ( ) . await
146
146
}
147
147
}
@@ -154,7 +154,7 @@ impl AuditLogger {
154
154
}
155
155
156
156
// read the oldest log file
157
- let oldest_file_path = CONFIG
157
+ let oldest_file_path = PARSEABLE
158
158
. options
159
159
. audit_log_dir
160
160
. join ( format ! ( "{}.json" , self . oldest_log_file_id) ) ;
@@ -180,8 +180,8 @@ impl AuditLogger {
180
180
. header ( "x-p-stream" , "audit_log" ) ;
181
181
182
182
// Use basic auth if credentials are configured
183
- if let Some ( username) = CONFIG . options . audit_username . as_ref ( ) {
184
- req = req. basic_auth ( username, CONFIG . options . audit_password . as_ref ( ) )
183
+ if let Some ( username) = PARSEABLE . options . audit_username . as_ref ( ) {
184
+ req = req. basic_auth ( username, PARSEABLE . options . audit_password . as_ref ( ) )
185
185
}
186
186
187
187
// Send batched logs to the audit logging backend
@@ -204,7 +204,7 @@ impl AuditLogger {
204
204
205
205
// spawn the batcher
206
206
tokio:: spawn ( async move {
207
- let mut interval = interval ( CONFIG . options . audit_flush_interval ) ;
207
+ let mut interval = interval ( PARSEABLE . options . audit_flush_interval ) ;
208
208
loop {
209
209
select ! {
210
210
_ = interval. tick( ) => {
0 commit comments