File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ use std::{
2121 cell:: RefCell ,
2222 ffi:: c_char,
2323 ptr:: { null, null_mut} ,
24- sync:: Arc ,
24+ sync:: { Arc , Once } ,
2525} ;
2626
2727use env_logger:: Env ;
@@ -37,10 +37,14 @@ thread_local! {
3737/// Enables logging in the TypeDB driver.
3838#[ no_mangle]
3939pub extern "C" fn init_logging ( ) {
40- const ENV_VAR : & str = "TYPEDB_DRIVER_LOG_LEVEL" ;
41- if let Err ( err) = env_logger:: try_init_from_env ( Env :: new ( ) . filter ( ENV_VAR ) ) {
42- warn ! ( "{err}" ) ;
43- }
40+ static INIT : Once = Once :: new ( ) ;
41+
42+ INIT . call_once ( || {
43+ const ENV_VAR : & str = "TYPEDB_DRIVER_LOG_LEVEL" ;
44+ if let Err ( err) = env_logger:: try_init_from_env ( Env :: new ( ) . filter ( ENV_VAR ) ) {
45+ warn ! ( "Failed to initialize logging: {}" , err) ;
46+ }
47+ } ) ;
4448}
4549
4650fn ok_record < T > ( result : Result < T > ) -> Option < T > {
You can’t perform that action at this time.
0 commit comments