0.0
No release in over a year
LiteLogger provides customizable log levels, formats, and destinations.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 13.0
~> 3.0
~> 1.21
 Project Readme

LiteLogger

LiteLogger is a lightweight logging solution for Ruby applications, providing customizable log levels, formats, and destinations.

Status

Gem Version

Installation

Add this line to your application's Gemfile:

gem 'lite_logger'

And then run:

bundle install

Or install it manually with:

gem install lite_logger

Usage

Basic example

In a Ruby class:

require 'lite_logger'

class MyClass
  def initialize
    @logger = LiteLogger::Logger.new
  end

  def run
    @logger.debug('This is a debug message')
    @logger.info('This is an info message')
    @logger.warn('This is a warning message')
    @logger.error('This is an error message')
    @logger.fatal('This is a fatal message')

  end
end

Logging to a file

require 'lite_logger'

logger = LiteLogger::Logger.new
logger.destination = './log/application.log'
logger.info('Application started!')

Output:

2024-07-10 18:58:07 -0300 [INFO] Application started!

Parent directories are created automatically when the destination is a file path.

JSON output

require 'lite_logger'

logger = LiteLogger::Logger.new
logger.format = :json
logger.info('Application started!')

Example output:

{"level":"info","message":"Application started!","timestamp":"2026-03-29 21:00:00 -0300"}

Custom formatter

Use formatter when you need full control over the rendered log line.

require 'lite_logger'
require 'time'

logger = LiteLogger::Logger.new
logger.destination = './log/custom.log'
logger.formatter = lambda do |level, message, time|
  "[#{time.iso8601}] #{level.upcase}: #{message}"
end

logger.info('Application started!')

Global configuration

require 'lite_logger'

LiteLogger.configure do |logger|
  logger.level = :debug
  logger.destination = './log/application.log'
end

LiteLogger.logger.info('Application started!')

Contributing

Bug reports and pull requests are welcome: https://github.com/dmferrari/lite_logger/pulls.

License

This little gem is available as open-source under the terms of the MIT License (see the LICENSE file in the project root for details).