Skip to content

4ndyfix/collog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

collog - colorized logging

collog is a library for colored logging output. The default usage colorizes the available log levels in different colors. But it is also possible to customize all log levels and all format fields. This is done by monkey-patching the standard log library. For further examples have a look at the specs.

Crystal CI GitHub release

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      collog:
        github: 4ndyfix/collog
  2. Run shards install

Usage

require "collog"

class SimpleLogExample
  Log = ::Log.for self.name

  def initialize
    ::Log.colorized = true
    ::Log.setup :trace
  end

  def run
    Log.trace { "This is a trace message." }
    Log.debug { "This is a debug message." }
    Log.info { "This is an info message." }
    Log.warn { "This is a warn message!" }
    Log.error { "This is an error message!!" }
    raise "raised!"
  rescue exc
    Log.fatal(exception: exc) { "This is a fatal message!!!" }
  end
end

SimpleLogExample.new.run

Contributing

  1. Fork it (https://github.com/your-github-user/collog/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

About

colorized logging

Resources

License

Stars

Watchers

Forks

Packages

No packages published