tracia 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6db85d92c978e016973febaede7a1365f0c6f1c56da05d5eeda4e4e72f7d4228
4
- data.tar.gz: 25180162f25501cb45a9e72c549db166c9b3b493655a4cf1fee3fc459e13c684
3
+ metadata.gz: a057298224487297c5fb36d4a5d2ca15afae37f64badea7e9dbece913d43cee1
4
+ data.tar.gz: 900c6b6927dceb17767762d0624866935c68dfe27a93d053af3d0c3621d96843
5
5
  SHA512:
6
- metadata.gz: bf1293d617f0e8c94feaca3dccf0cd826a8cb745993cadb5d9281d25baaf5a1308666e75828c6e1ec25ef7d3c5c38ce7e8aeb17e8c0b2da1dafa973f306e984a
7
- data.tar.gz: 1ba8344769fe6b565bfdd405b3f68ad5aec0c08584d13f12e06725c68020b68f3bc531c92dcb848e7767ae88868fbb4cb635eee7169042f0c195c47cbc707e27
6
+ metadata.gz: 539b4c266dfba8dd44f219f4cf3c9b52487ce20c7dac9c8d9609d162e74ead02e043b2966a537d3a220c5822dc8b92f1dc1c9ccdfe93de48c687807707827385
7
+ data.tar.gz: 9a1dcc702267fd56461b7448aa4aae5ef5df83193ba82e36b36c57a6ac9bac5a17d29c5a0bb396a9377d82b57b38295c9315525fa2a274acfdcce5048253c868
data/README.md CHANGED
@@ -42,7 +42,17 @@ end
42
42
 
43
43
  ### Custom Logger
44
44
 
45
- A Template to make custom logger
45
+ By default, Tracia writes result to STDOUT, you can set it somewhere else
46
+
47
+ ```ruby
48
+ file = File.new('/path/to/log.txt', 'w+')
49
+
50
+ Tracia.start(logger: Tracia::DefaultLogger.new(out: file)) do
51
+ # ...
52
+ end
53
+ ```
54
+
55
+ Or you can make a logger class which responds to `call`
46
56
 
47
57
  ```ruby
48
58
  class MyLogger
@@ -50,6 +60,7 @@ class MyLogger
50
60
  @database = database
51
61
  end
52
62
 
63
+ # callback method for Tracia
53
64
  def call(root)
54
65
  # ...
55
66
  @database.insert(root)
@@ -57,7 +68,7 @@ class MyLogger
57
68
  end
58
69
  ```
59
70
 
60
- Pass the custom logger to Tracia
71
+ Then pass that logger to Tracia
61
72
 
62
73
  ```ruby
63
74
  Tracia.start(logger: MyLogger.new(db_connection)) do
data/lib/tracia/frame.rb CHANGED
@@ -7,11 +7,11 @@ class Tracia
7
7
  attr_reader :klass, :call_sym, :method_name, :children, :file
8
8
 
9
9
  def initialize(klass, call_sym, method_name, file, lineno)
10
- @file = file
11
- @lineno = lineno
12
10
  @klass = klass
13
11
  @call_sym = call_sym
14
12
  @method_name = method_name
13
+ @file = file
14
+ @lineno = lineno
15
15
  @children = []
16
16
  end
17
17
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Tracia
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
data/lib/tracia.rb CHANGED
@@ -18,7 +18,7 @@ class Tracia
18
18
  def start(**opt)
19
19
  trc = (Thread.current[:_tracia_] ||= new(**opt))
20
20
  trc.level += 1
21
- trc.depth = binding.frame_count - 4
21
+ trc.depth = binding.frame_count - 3
22
22
  yield
23
23
  rescue StandardError => e
24
24
  trc.error = e
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken