@@ -100,27 +100,40 @@ pub fn init_runtime () -> std::io::Result<Runtime> {
100
100
}
101
101
}
102
102
103
- pub fn init_configs ( cmd : Cmd ) -> std:: io:: Result < ( ) > {
103
+ pub fn init_configs ( cmd : Cmd ) -> std:: io:: Result < ( ) > {
104
104
//init logger
105
105
env_logger:: builder ( )
106
- . format ( |buf, rec| {
106
+ . format ( |buf, rec| {
107
107
let style = buf. default_level_style ( rec. level ( ) ) ;
108
- writeln ! ( buf, "[{} {style}{}{style:#} librespeed_rs] {}" , current_formatted_time( ) , rec. level( ) , rec. args( ) )
108
+ writeln ! (
109
+ buf,
110
+ "[{} {style}{}{style:#} {}:{}] {}" ,
111
+ current_formatted_time( ) ,
112
+ rec. level( ) ,
113
+ rec. file( ) . unwrap_or( "unknown" ) ,
114
+ rec. line( ) . unwrap_or( 0 ) ,
115
+ rec. args( )
116
+ )
109
117
} )
110
- . filter_level ( LevelFilter :: Info ) . init ( ) ;
118
+ . filter_level ( LevelFilter :: Info )
119
+ . init ( ) ;
111
120
println ! ( "{HEAD_ART}" ) ;
112
121
//find server configs
113
122
match cmd. server_config_path . clone ( ) {
114
123
Some ( config_path) => {
115
124
let config = open_config_file ( & config_path) ;
116
125
match config {
117
126
Ok ( config) => {
118
- initialize ( config, cmd) ?;
119
- info ! ( "Configs initialized file : {}" , config_path) ;
127
+ initialize ( config, cmd) ?;
128
+ info ! ( "Configs initialized file : {}" , config_path) ;
120
129
Ok ( ( ) )
121
130
}
122
131
Err ( e) => {
123
- Err ( Error :: new ( ErrorKind :: Other , e) )
132
+ trace ! ( "Failed to load config from {}: {}" , config_path, e) ;
133
+ Err ( Error :: new (
134
+ ErrorKind :: Other ,
135
+ format ! ( "Could not load config from {}: {}" , config_path, e) ,
136
+ ) )
124
137
}
125
138
}
126
139
}
@@ -129,16 +142,16 @@ pub fn init_configs (cmd : Cmd) -> std::io::Result<()> {
129
142
match config {
130
143
// open config from current dir
131
144
Ok ( config) => {
132
- initialize ( config, cmd) ?;
145
+ initialize ( config, cmd) ?;
133
146
info ! ( "Configs initialized file : configs.toml" ) ;
134
147
Ok ( ( ) )
135
148
}
136
149
// set default config
137
150
Err ( e) => {
138
151
let config = ServerConfig :: default ( ) ;
139
- initialize ( config, cmd) ?;
152
+ initialize ( config, cmd) ?;
140
153
info ! ( "Configs initialized with defaults" ) ;
141
- trace ! ( "Load config default path error : {}" , e) ;
154
+ trace ! ( "Load config default path error : {}" , e) ;
142
155
Ok ( ( ) )
143
156
}
144
157
}
0 commit comments