README.md in loba-1.2.1 vs README.md in loba-2.0.0

- old
+ new

@@ -1,35 +1,35 @@ +# Loba + [![Gem Version](https://badge.fury.io/rb/loba.svg)](https://badge.fury.io/rb/loba) -[![Build Status](https://app.travis-ci.com/rdnewman/loba.svg?branch=main)](https://app.travis-ci.com/rdnewman/loba) +[![Build Status](https://github.com/rdnewman/loba/actions/workflows/ruby.yml/badge.svg?branch=main)](https://github.com/rdnewman/loba/actions?query=branch%3Amain++) [![Code Climate](https://codeclimate.com/github/rdnewman/loba/badges/gpa.svg)](https://codeclimate.com/github/rdnewman/loba) [![Test Coverage](https://codeclimate.com/github/rdnewman/loba/badges/coverage.svg)](https://codeclimate.com/github/rdnewman/loba/coverage) -[![Inline docs](http://inch-ci.org/github/rdnewman/loba.svg?branch=master)](http://inch-ci.org/github/rdnewman/loba) -[![security](https://hakiri.io/github/rdnewman/loba/main.svg)](https://hakiri.io/github/rdnewman/loba/main) -# Loba - ![Loba is "write" in Zulu](readme/zulu.png) Easy tracing for debugging: handy methods for adding trace lines to output or Rails logs. (Installation is pretty much what you'd expect for a gem, but read Environment Notes below first.) ## Overview There are two kinds of questions I usually want to answer when trying to diagnose code behavior: -1. Is this spot of code being reached (or is it reached in the order I think it is)? -1. What is the value of this variable? +1. Is this spot of code being reached (or is it reached in the order I think it is)? +1. What is the value of this variable? Loba statements are intended to be terse to minimize typing. Loba statements are intended to be minimally invasive and atomic. They should not have any (much) more impact than regular `puts` or `Rails.logger.debug` statements. Loba statements are expected to be removed when you're done with them. No point in cluttering up production code. -Loba will check for presence of Rails. If it's there, it'll write to `Rails.logger.debug`. If not, it'll write to STDOUT (i.e., `puts`). Loba will work equally well with or without Rails. +Loba will always write to STDOUT (i.e., `puts`). +Loba will work equally well with or without Rails. If Rails is present, in addition to STDOUT, Loba will also always write to `Rails.logger.debug`. + Loba uses the [rainbow gem](https://rubygems.org/gems/rainbow) to help make trace statements more visible. ## Usage My advice is to align Loba statements to the far left in your source code (a la `=begin` or `=end`) so they're easy to see and remove when you're done. @@ -38,11 +38,11 @@ Outputs a timestamped notice, useful for quick traces to see the code path and easier than, say, [Kernel#set_trace_func](http://ruby-doc.org/core-2.2.3/Kernel.html#method-i-set_trace_func). Also does a simple elapsed time check since the previous timestamp notice to help with quick, minimalist profiling. For example, -``` +```text [TIMESTAMP] #=0002, diff=93.478016, at=1451444972.970602 (in=/home/usracct/src/myapp/app/models/target.rb:55:in `some_calculation') ``` To invoke, @@ -62,11 +62,11 @@ Loba.val :var_sym # the :var_sym argument is the variable or method name given as a symbol ``` For example, -``` +```text [Target.some_calculation] my_var: 54 (in /home/usracct/src/myapp/app/models/target.rb:55:in `some_calculation') ``` You can read [more detail](readme/val.md) on this command. @@ -90,11 +90,11 @@ HelloWorld.new.hello ``` Output: -``` +```text [TIMESTAMP] #=0001, diff=0.000463, at=1451615389.505411 (in=/home/usracct/src/lobademo/hello_world.rb:4:in 'initialize' [HelloWorld#hello] @x: 42 (in /home/usracct/src/loba/spec/hello_world.rb:9:in `hello') Hello, Charlie [TIMESTAMP] #=0002, diff=0.000720, at=1451615389.506132 (in=/home/usracct/src/lobademo/hello_world.rb:11:in 'hello' ``` @@ -105,11 +105,11 @@ The expectation is that Loba statements are just for development or test trace statements. Generally, it's a bad idea to leave diagnostic code in Rails production; still, it can happen. And, occasionally, it can be useful to have trace statements in production too if you have an issue that is difficult to reproduce. `Loba.ts` and `Loba.val` try to protect against timestamp or value notice requests being accidentally left in the code by checking for the Rails environment Loba is being invoked under. If in production, `Loba.ts` and `Loba.val` will normally just return immediately without attempting to render anything to help minimize any impact on production code. -However, that behavior can be overridden by using the options hash with `:production => true` as an additional last argument to output a notice even when in the production environment. In general, this should be avoided. +However, that behavior can be overridden by using the options hash with `:production => true` as an additional last argument to output a notice even when in the production environment. Note also behavior of the `log` option which defaults to `false` (introduced in v2.0.0). In general, enabling in production should be avoided. We're consenting adults. WARNING: this gem depends on the [binding_of_caller gem](https://rubygems.org/gems/binding_of_caller) -- use `:production => true` with their warning in mind: > **Recommended for use only in debugging situations. Do not use this in production apps.** These considerations also have an impact on how you install the Loba gem when using `bundler`. If you only install the gem for :development and :test, then any Loba statements left in the code when it goes to production will cause an error because the statements wouldn't be recognized. That's usually a Good Thing, if you never want them left in. @@ -137,15 +137,14 @@ ## Installation See above Environment Notes if using with Rails. - Install as below to be generally available (recommended to restrict to only local use): ```bash -$ gem install loba +gem install loba ``` To bundle, add this line to your application's Gemfile: ```ruby @@ -158,21 +157,22 @@ ```ruby gem 'loba', require: false ``` - And then execute: ```bash -$ bundle +bundle ``` ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. 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](https://rubygems.org). +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](https://rubygems.org). ## Changelog See [CHANGELOG.md](CHANGELOG.md) for details. This gem follows semantic versioning.