-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make docs more consistant; lint markdown (#43)
- Loading branch information
Showing
3 changed files
with
54 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,66 @@ | ||
#### Timestamp notices: `Loba.ts` | ||
|
||
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, | ||
|
||
``` | ||
```ruby | ||
Loba.ts # no arguments | ||
``` | ||
|
||
`Loba.timestamp` is an alias for `Loba.ts`. | ||
|
||
The resulting notice output format is | ||
|
||
``` | ||
```text | ||
[TIMESTAMP] #=nnnn, diff=ss.ssssss, at=tttttttttt.tttttt (in=/path/to/code/somecode.rb:LL:in 'some_method') | ||
``` | ||
|
||
where | ||
* `nnn` ("#=") is a sequential numbering (1, 2, 3, ...) of timestamp notices, | ||
* `ss.ssssss` ("diff=") is number of seconds since the last timestamp notice was output (i.e., relative time), | ||
* `tttttttttt.tttttt` ("at=") is Time.now (as seconds) (i.e., absolute time), | ||
* `/path/to/code/somecode.rb` ("in=") is the source code file that invoked `Loba.ts`, | ||
* `LL` ("in=...:") is the line number of the source code file that invoked `Loba.ts`, and | ||
* `some_method` is the method in which `Loba.ts` was invoked. | ||
|
||
* `nnn` ("#=") is a sequential numbering (1, 2, 3, ...) of timestamp notices, | ||
* `ss.ssssss` ("diff=") is number of seconds since the last timestamp notice was output (i.e., relative time), | ||
* `tttttttttt.tttttt` ("at=") is Time.now (as seconds) (i.e., absolute time), | ||
* `/path/to/code/somecode.rb` ("in=") is the source code file that invoked `Loba.ts`, | ||
* `LL` ("in=...:") is the line number of the source code file that invoked `Loba.ts`, and | ||
* `some_method` is the method in which `Loba.ts` was invoked. | ||
|
||
##### Options | ||
|
||
The following keyword argument may be specified when calling: | ||
* `production`: true if this timestamp notice is to be enabled when running in :production environment (see ["Environment Notes"](README.md#environment-notes)) \[_default: `false`_\] | ||
* `log`: `true` true if output is to be sent to both $STDOUT and to the Rails.logger (when available) | ||
|
||
* `production`: true if this timestamp notice is to be enabled when running in :production environment (see ["Environment Notes"](README.md#environment-notes)) \[_default: `false`_\] | ||
* `log`: `true` true if output is to be sent to both STDOUT and to the Rails.logger (when available) \[_default: `false`_\] | ||
|
||
###### Examples using options | ||
|
||
```ruby | ||
Loba.ts production: true | ||
``` | ||
|
||
```ruby | ||
Loba.ts(production: true) | ||
``` | ||
|
||
```ruby | ||
Loba.ts log: true | ||
``` | ||
|
||
```ruby | ||
Loba.ts(log: true) | ||
``` | ||
|
||
```ruby | ||
Loba.ts production: true, log: true # may result in double logging | ||
``` | ||
|
||
```ruby | ||
Loba.ts(production: true, log: true # may result in double logging) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters