33use self :: sealed:: KVs ;
44use crate :: { Level , Metadata , Record } ;
55use std:: fmt:: Arguments ;
6- pub use std:: { file, format_args, line, module_path, stringify} ;
6+ use std:: panic:: Location ;
7+ pub use std:: { format_args, module_path, stringify} ;
78
89#[ cfg( not( feature = "kv" ) ) ]
910pub type Value < ' a > = & ' a str ;
@@ -36,8 +37,7 @@ impl<'a> KVs<'a> for () {
3637fn log_impl (
3738 args : Arguments ,
3839 level : Level ,
39- & ( target, module_path, file) : & ( & str , & ' static str , & ' static str ) ,
40- line : u32 ,
40+ & ( target, module_path, loc) : & ( & str , & ' static str , & ' static Location ) ,
4141 kvs : Option < & [ ( & str , Value ) ] > ,
4242) {
4343 #[ cfg( not( feature = "kv" ) ) ]
@@ -52,8 +52,8 @@ fn log_impl(
5252 . level ( level)
5353 . target ( target)
5454 . module_path_static ( Some ( module_path) )
55- . file_static ( Some ( file) )
56- . line ( Some ( line) ) ;
55+ . file_static ( Some ( loc . file ( ) ) )
56+ . line ( Some ( loc . line ( ) ) ) ;
5757
5858 #[ cfg( feature = "kv" ) ]
5959 builder. key_values ( & kvs) ;
@@ -64,25 +64,23 @@ fn log_impl(
6464pub fn log < ' a , K > (
6565 args : Arguments ,
6666 level : Level ,
67- target_module_path_and_file : & ( & str , & ' static str , & ' static str ) ,
68- line : u32 ,
67+ target_module_path_and_loc : & ( & str , & ' static str , & ' static Location ) ,
6968 kvs : K ,
7069) where
7170 K : KVs < ' a > ,
7271{
73- log_impl (
74- args,
75- level,
76- target_module_path_and_file,
77- line,
78- kvs. into_kvs ( ) ,
79- )
72+ log_impl ( args, level, target_module_path_and_loc, kvs. into_kvs ( ) )
8073}
8174
8275pub fn enabled ( level : Level , target : & str ) -> bool {
8376 crate :: logger ( ) . enabled ( & Metadata :: builder ( ) . level ( level) . target ( target) . build ( ) )
8477}
8578
79+ #[ track_caller]
80+ pub fn loc ( ) -> & ' static Location < ' static > {
81+ Location :: caller ( )
82+ }
83+
8684#[ cfg( feature = "kv" ) ]
8785mod kv_support {
8886 use crate :: kv;
0 commit comments