Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
/ null-logger Public archive

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

License

Notifications You must be signed in to change notification settings

karafka/null-logger

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Languages