Coder Social home page Coder Social logo

Comments (4)

KodrAus avatar KodrAus commented on June 2, 2024 1

Hi @sallyyu0 👋

There are a few things going on here.

All logs still go to console. Is not it supposed to be different?

Your logs should end up being written to stdout and appear in your terminal. Is the problem that you're running cargo test and your logs are suddenly showing up there instead of being captured like println! is?

Note that I did get following error and not sure why So I made change as instructed by adding "self", it passed.

This one is Rust itself being picky. Usually you only put extern crate ..; statements in your root lib.rs or main.rs. When you do that you can just use ..; in other modules like logger.rs.

INFO 2018-11-02T19:17:37Z: myapp::utils::logger: builder=Logger { filter: Filter { filter: None, directives: [] }, writer: Logger { target: Stdout, write_style: Auto } }

This one is our bad. That Logger { .. } is actually lying about its fields. After calling builder.init() we replace those fields with default values so it doesn't tell you what the Builder looked like before. I opened #110 to fix that up.

from env_logger.

KodrAus avatar KodrAus commented on June 2, 2024 1

I was hoping a way NOT to print the logs to the terminal instead to a file, or a server

Ah right. Yeh, env_logger only supports logging to a terminal. If you'd like to send your logs elsewhere you could take a look at log4rs which has rolling file support.

access to extern crates through prelude is experimental

I think this is another picky modules error. You shouldn't need the extern crate env_logger; statement in your logger.rs file, but you might instead need a use env_logger; statement. These are nasty little papercuts that are cleaned up in a new edition of the language. If you transition your project to the current 2018 edition then you shouldn't need any extern crate env_logger or use env_logger; statements at all.

from env_logger.

sallyyu0 avatar sallyyu0 commented on June 2, 2024

Hi KodrAus,
Thanks for the response. I was hoping a way NOT to print the logs to the terminal instead to a file, or a server even though I see there are only two options, stderr and stdout.

About the build error: When I don't have "extern crate env_logger;", I get this error instead.
error[E0658]: access to extern crates through prelude is experimental (see issue #44660)

from env_logger.

KodrAus avatar KodrAus commented on June 2, 2024

It looks we've worked through your original concerns @sallyyu0 so I'll go ahead and close this one now. Please feel free to re-open it or start a new issue if there's anything else you'd like to clarify!

from env_logger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.