GithubHelp home page GithubHelp logo

method_logger's Introduction

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.

method_logger's People

Contributors

bbonislawski avatar

Stargazers

Tomasz Dębek avatar Damian Legawiec avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.