ExtLogger

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file lib/ext_logger. To experiment with that code, run bin/console for an interactive prompt.

Extended Logger class, log output to console in non-production environment. 
Other extensions see version updates.
2019-01-22(0.2.6): 
    Fix some bugs.
    Add method: analysis_exception to Common module.
    Fix module extend class method bug.

2019-01-21(0.2.4): 
    Fix some bugs.
    Common methods are extracted into separate modules for later use by other classes.

2019-01-20(0.2.3): 
    Fix some bugs.

2018-12-25(0.2.2): 
    The internal structure changes greatly. 
    Adding hash parameters: 
        :log_max_num (keep the latest number of log files according to the parameter values, and delete the redundancy), 

2018-12-06(0.2.1): 
    The internal structure changes greatly. 
    Adding Exception Output Processing:
        logger.exception(e) # The 'e' is exception object.
    Adding hash parameters: 
        :age (shift_age with Logger object), 
        :size (shift_size with Logger object), 
        :split_format (log file output according to Ruby time format).

2018-11-28(0.1.3): 
    Additional instance method ‘record_memory’ to record memory consumption. 
    Fixed a path problem during log initialization.

Installation

Add this line to your application's Gemfile:

gem 'ext_logger'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ext_logger

Usage

  1. Initialization object (It automatically creates non-existent directories based on paths):
    logger = ExtLogger.new(log_path, {age: 7/'weekly', size: 1024000, split_format: '%Y%m%d%H%M', log_max_num: 5})
  1. Output normal log (Extended logger.info):
    logger.info("log content")
  1. Output debug log (Extended logger.info):
    logger.debug("log content")
  1. Output error log (Extended logger.error):
    logger.error("log content")
  1. Output warning log (Extended logger.warn):
    logger.warn("log content")
  1. Output fatal log (Extended logger.fatal):
    logger.fatal("log content")
  1. Output exception log (Extended logger.error):
    logger.exception(e) # when rescure Exception => e
  1. Output memory usage (Extended logger.warn):
    logger.record_memory        # at the begin of programme
    logger.record_memory('end') # at the end of programme

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mst_ruby/ext_logger.

License

The gem is available as open source under the terms of the MIT License.