Giter Site home page Giter Site logo

log4cr's People

Contributors

billiam105 avatar michionlion avatar

Watchers

 avatar  avatar

log4cr's Issues

*ignore*

After bugtesting this issue is not one.

Child loggers set to a more specific debug level than their parents will still log to their parents's appenders

As an example of the confusing behavior, see the following failing spec.

Note: as a workaround, you can set the level of the root (or offending) Appender to the same as it's Logger.

it "logs from child loggers but not from parents in the correct circumstances" do
    # root logger setup
    io = IO::Memory.new
    root_appender = Log4cr::Appender.new io
    root_appender.formatter = Logger::Formatter.new do |severity, datetime, progname, message, io|
      io << "[ROOT] " << message
    end
    Log4cr::Logger.root_logger.add_appender root_appender
    Log4cr::Logger.root_logger.level = ::Logger::INFO

    # child logger setup
    child_appender = Log4cr::Appender.new io
    child_appender.formatter = Logger::Formatter.new do |severity, datetime, progname, message, io|
      io << "[CHILD] " << message
    end
    Log4cr::Logger.get("base.special").add_appender child_appender
    Log4cr::Logger.get("base.special").level = ::Logger::DEBUG

    # logging
    Log4cr::Logger.root_logger.info("this should log to root")
    Log4cr::Logger.root_logger.debug("this should not log to anything")
    Log4cr::Logger.get("base").info("this should log to root again")
    Log4cr::Logger.get("base").debug("this should also not log to anything")
    Log4cr::Logger.get("base.special").debug("this should log to child but not root")
    Log4cr::Logger.get("base.special").info("this should log to child AND root")

    # expectation
    io.to_s.should eq <<-END
    [ROOT] this should log to root
    [ROOT] this should log to root again
    [CHILD] this should log to child but not root
    [CHILD] this should log to child AND root
    [ROOT] this should log to child AND root\n
    END
  end

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.