@@ -75,8 +75,19 @@ impl<'a> tracing_subscriber::fmt::MakeWriter<'a> for TerminalPrinterMaker {
7575 }
7676}
7777
78- pub fn init_logging ( our : & Address , level : Level ) {
79- let file_filter = EnvFilter :: new ( level. as_str ( ) ) ;
78+ /// Initialize `tracing`-based logging for the given process at the given level.
79+ ///
80+ /// To write to logs, import the re-exported `debug!`, `info!`, `warn!`, `error!`
81+ /// macros and use as usual. Logs will be printed to terminal as appropriate depending
82+ /// on given level. Logs will be logged into the logging file as appropriate depending
83+ /// on the given level.
84+ ///
85+ /// The logging file lives in the node's `vfs/` directory, specifically at
86+ /// `node/vfs/package:publisher.os/log/process.log`, where `node` is your node's home
87+ /// directory, `package` is the package name, `publisher.os` is the publisher of the
88+ /// package, and `process` is the process name of the process doing the logging.
89+ pub fn init_logging ( our : & Address , file_level : Level , terminal_level : Level ) {
90+ let file_filter = EnvFilter :: new ( file_level. as_str ( ) ) ;
8091 let error_filter = tracing_subscriber:: filter:: filter_fn ( |metadata : & tracing:: Metadata < ' _ > | {
8192 metadata. level ( ) == & Level :: ERROR
8293 } ) ;
@@ -121,7 +132,7 @@ pub fn init_logging(our: &Address, level: Level) {
121132 ) ;
122133
123134 // TODO: can we DRY?
124- if level >= Level :: DEBUG {
135+ if terminal_level >= Level :: DEBUG {
125136 sub. with (
126137 fmt:: layer ( )
127138 . without_time ( )
@@ -153,7 +164,7 @@ pub fn init_logging(our: &Address, level: Level) {
153164 . with_filter ( debug_filter) ,
154165 )
155166 . init ( ) ;
156- } else if level >= Level :: INFO {
167+ } else if terminal_level >= Level :: INFO {
157168 sub. with (
158169 fmt:: layer ( )
159170 . without_time ( )
@@ -175,7 +186,7 @@ pub fn init_logging(our: &Address, level: Level) {
175186 . with_filter ( info_filter) ,
176187 )
177188 . init ( ) ;
178- } else if level >= Level :: WARN {
189+ } else if terminal_level >= Level :: WARN {
179190 sub. with (
180191 fmt:: layer ( )
181192 . without_time ( )
0 commit comments