0.0
No commit activity in last 3 years
No release in over 3 years
Gem that logs all method calls in your class
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.15
~> 10.0
~> 3.0
 Project Readme

MethodLogger

Ultra simple gem that contains module that you can include to any class to log all method calls to standard output or/and file.

Installation

Add this line to your application's Gemfile:

gem 'method_logger'

And then execute:

$ bundle

Or install it yourself as:

$ gem install method_logger

Usage

Include mixin at the end of your class like this:

include MethodLogger::mixin({})

You can customize it by passing options to mixin in hash:

{
  include_inherited: true, # determines if should include inherited methods
  ignored_methods: [], # [Array of symbols] used to ignore methods that we don't need to see
  logger: Logger.new(File.open(options[:filename], 'a+')), # if you don't like basic ruby logger, you can pass your own. It
  must respond to #info
  formatter: DefaultFormatter.new, # this is used for formatting. You can pass any object that responds to #call method
  filename: 'method_logger_log.txt', # filename to put logs in default logger
  log_to_file: false ,# determines if it should log to file
  log_to_stdout: true # determines if it should log to standard output
}

Example

Simple example output for active record model with just 1 field in fresh project :

class Project < ApplicationRecord
  include MethodLogger::mixin({ log_to_file: true, filename: 'example.output' })
end

Example output

Contributing

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

License

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