#Need a fast library to write logs to a file, does tracing do this?

22 messages ยท Page 1 of 1 (latest)

south apex
#

Need a fast library to write logs to a file, does tracing do this?

analog wigeon
#

The standard is the log crate, it is used by pretty much all libraries (which need) to log messages of different log levels

#

So you get both output of libraries that need to log, and you can log stuff yourself

#

Note however that the log crate doesn't do logging, it is merely a logging abstraction which is logger-agnostic

#

Libraries and binaries can use the log crate's macros but without a logger registered they will do nothing

#

Although if you are in need of async logging then there's likely a better implementation you can write depending on your project (it's not hard to write a logger at all)

south apex
#

but the log api doesn't support logging to file

analog wigeon
#

It does, as I explained the log crate is logger-agnostic. You can have any code logging on one end (using log macros) and a logger on the other end receiving those records and doing whatever it wants with them

south apex
#

i'm not sure i follow. i don't want to implement my own write to file -- i'd like it built in, and as far as i can tell, log doesn't have a write to file macro so it depends on the specific implementation decides to include it in their library api, e.g. env-logger doesn't support logging to file and i have to implement it myself

#

i'm not sure fast_log is production ready, i was looking tracing bc it appears to be the most popular

#

and log4rs for example, which does support writing to file, is too slow for my application

analog wigeon
#

ahh then yes it's probably best to use tracing, if you're using something like Tokio

#

For some reason I assumed you are talking about a sync application ๐Ÿ˜…

south apex
#

yeah sorry i forgot to mention that, i'm using tokio in my application

analog wigeon
#

Yeah then tracing is golden

south apex
#

but do you know if it has a write to file implementation?

analog wigeon
#

tracing is also logger-agnostic, although they call them subscribers