0.07
Repository is archived
No commit activity in last 3 years
No release in over 3 years
It can be used for defining an interface for other loggers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Null Logger [Unmaintained]

Note: This library is no longer in use in the Karafka ecosystem. It was developed for Karafka versions prior to 1.0. If you're using this library and want to take it over, please ping us.

Build Status Gem Version Join the chat at https://slack.karafka.io

A simple logger that does not log anything. It can be used for defining an interface for other loggers.

Installation

Add the gem to your Gemfile

  gem 'null-logger', require: 'null_logger'

Usage

On NullLogger instance you can call methods which correspond to Ruby Logger log levels (unknown, fatal, error, warn, info, debug), ex:

  NullLogger.new.fatal # return nil
  NullLogger.new.wrong_method # raise NoMethodError

NullLogger defines an interface for real logger instance, ex:

  class Worker
    class << self
      attr_writer :logger

      def logger
        @logger ||= NullLogger.new
      end

      def method()
        # some code
      rescue => exception
        self.class.logger.fatal(exception)
        raise exception
      end
    end
  end