K Log
K Log provides console logging helpers and formatters
This code is old and probably needs to be written differently, but it solves my problem of having formatted console logging within different Apps and Gems that I write.
Installation
Add this line to your application's Gemfile:
gem 'k_log'And then execute:
bundle installOr install it yourself as:
gem install k_logStories
Main Story
As a Developer, I need formatted console logs, so that information presents clearly
See all stories
Usage
See all usage examples
Basic Example
Setup KLog
Pass a standard Logger to KLog and then setup an alias for easier access
KLog.logger = Logger.new($stdout)
KLog.logger.level = Logger::DEBUG
KLog.logger.formatter = KLog::LogFormatter.new
L = KLog::LogUtil.new(KLog.logger)Sample Usage
L.debug 'some debug message'
L.info 'some info message'
L.warn 'some warning message'
L.error 'some error message'
L.fatal 'some fatal message'
L.kv('First Name', 'David')
L.kv('Last Name', 'Cruwys')
L.kv('Age', 45)
L.kv('Sex', 'male')
L.heading('Heading')
L.subheading('Sub Heading')
L.block ['Line 1', 12, 'Line 3', true, 'Line 5']
L.progress(0, 'Section 1')
L.progress
L.progressDevelopment
Checkout the repo
git clone klueless-io/k_logAfter checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests.
k_log is setup with Guard, run guard, this will watch development file changes and run tests automatically, if successful, it will then run rubocop for style quality.
To release a new version, update the version number in version.rb, build the gem and push the .gem file to rubygems.org.
rake publish
rake cleanContributing
Bug reports and pull requests are welcome on GitHub at https://github.com/klueless-io/k_log. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the K Log project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Copyright
Copyright (c) David Cruwys. See MIT License for further details.
