leafy-rack 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +34 -4
  3. data/.travis.yml +19 -0
  4. data/CHANGELOG.md +7 -0
  5. data/Gemfile +1 -8
  6. data/README.md +10 -148
  7. data/examples/datadog/.gitignore +2 -0
  8. data/examples/datadog/Gemfile +12 -0
  9. data/examples/datadog/Mavenfile +22 -0
  10. data/examples/datadog/README.md +16 -0
  11. data/examples/datadog/lib/java_gauge.rb +20 -0
  12. data/examples/datadog/lib/metrics.rb +18 -0
  13. data/examples/datadog/lib/ruby_gauge.rb +19 -0
  14. data/examples/hellowarld/.gitignore +3 -0
  15. data/examples/hellowarld/Gemfile +15 -0
  16. data/examples/hellowarld/Mavenfile +162 -0
  17. data/examples/hellowarld/README.md +44 -0
  18. data/examples/hellowarld/Rakefile +13 -0
  19. data/examples/hellowarld/WEB-INF/web.xml +31 -0
  20. data/examples/hellowarld/app/hellowarld.rb +55 -0
  21. data/examples/hellowarld/app/views/person.erb +52 -0
  22. data/examples/hellowarld/config.ru +12 -0
  23. data/leafy-complete.gemspec +22 -0
  24. data/leafy-health/.gitignore +4 -0
  25. data/leafy-health/Gemfile +7 -0
  26. data/leafy-health/LICENSE +22 -0
  27. data/leafy-health/README.md +123 -0
  28. data/leafy-health/Rakefile +14 -0
  29. data/leafy-health/leafy-health.gemspec +27 -0
  30. data/leafy-health/lib/leafy-health.rb +2 -0
  31. data/leafy-health/lib/leafy-health_jars.rb +7 -0
  32. data/leafy-health/lib/leafy/health.rb +2 -0
  33. data/leafy-health/lib/leafy/health/health_check.rb +72 -0
  34. data/leafy-health/lib/leafy/health/registry.rb +55 -0
  35. data/leafy-health/lib/leafy/health/version.rb +6 -0
  36. data/leafy-health/spec/registry_spec.rb +164 -0
  37. data/leafy-health/spec/setup.rb +1 -0
  38. data/leafy-logger/.gitignore +5 -0
  39. data/leafy-logger/Gemfile +9 -0
  40. data/leafy-logger/LICENSE +22 -0
  41. data/leafy-logger/README.md +174 -0
  42. data/{Rakefile → leafy-logger/Rakefile} +0 -0
  43. data/leafy-logger/leafy-logger.gemspec +32 -0
  44. data/leafy-logger/lib/leafy-logger.rb +1 -0
  45. data/leafy-logger/lib/leafy-logger_jars.rb +33 -0
  46. data/leafy-logger/lib/leafy/logger.rb +1 -0
  47. data/leafy-logger/lib/leafy/logger/appender_factories.rb +89 -0
  48. data/leafy-logger/lib/leafy/logger/factory.rb +141 -0
  49. data/leafy-logger/lib/leafy/logger/version.rb +6 -0
  50. data/leafy-logger/spec/appender_factories_spec.rb +147 -0
  51. data/leafy-logger/spec/factory_spec.rb +176 -0
  52. data/leafy-logger/spec/logging.yml +16 -0
  53. data/leafy-logger/spec/setup.rb +2 -0
  54. data/leafy-metrics/.gitignore +5 -0
  55. data/leafy-metrics/Gemfile +7 -0
  56. data/leafy-metrics/LICENSE +22 -0
  57. data/leafy-metrics/README.md +221 -0
  58. data/leafy-metrics/Rakefile +14 -0
  59. data/leafy-metrics/leafy-metrics.gemspec +29 -0
  60. data/leafy-metrics/lib/leafy-metrics.rb +2 -0
  61. data/leafy-metrics/lib/leafy-metrics_jars.rb +5 -0
  62. data/leafy-metrics/lib/leafy/metrics.rb +2 -0
  63. data/leafy-metrics/lib/leafy/metrics/console_reporter.rb +32 -0
  64. data/leafy-metrics/lib/leafy/metrics/csv_reporter.rb +26 -0
  65. data/leafy-metrics/lib/leafy/metrics/graphite/graphite.rb +28 -0
  66. data/leafy-metrics/lib/leafy/metrics/graphite/graphite_reporter.rb +43 -0
  67. data/leafy-metrics/lib/leafy/metrics/registry.rb +108 -0
  68. data/leafy-metrics/lib/leafy/metrics/reporter.rb +51 -0
  69. data/leafy-metrics/lib/leafy/metrics/version.rb +6 -0
  70. data/leafy-metrics/spec/console_reporter_spec.rb +72 -0
  71. data/leafy-metrics/spec/csv_reporter_spec.rb +75 -0
  72. data/leafy-metrics/spec/graphite_reporter_spec.rb +72 -0
  73. data/leafy-metrics/spec/graphite_spec.rb +23 -0
  74. data/leafy-metrics/spec/registry_spec.rb +106 -0
  75. data/leafy-metrics/spec/setup.rb +10 -0
  76. data/leafy-rack/.gitignore +4 -0
  77. data/leafy-rack/Gemfile +10 -0
  78. data/leafy-rack/LICENSE +22 -0
  79. data/leafy-rack/README.md +155 -0
  80. data/leafy-rack/Rakefile +14 -0
  81. data/{leafy-rack.gemspec → leafy-rack/leafy-rack.gemspec} +2 -2
  82. data/{lib → leafy-rack/lib}/leafy-rack.rb +0 -0
  83. data/{lib → leafy-rack/lib}/leafy-rack_jars.rb +0 -0
  84. data/{lib → leafy-rack/lib}/leafy/instrumented/basic_instrumented.rb +0 -0
  85. data/{lib → leafy-rack/lib}/leafy/instrumented/instrumented.rb +0 -0
  86. data/{lib → leafy-rack/lib}/leafy/json/health_writer.rb +0 -0
  87. data/{lib → leafy-rack/lib}/leafy/json/json_writer.rb +0 -0
  88. data/{lib → leafy-rack/lib}/leafy/json/metrics_writer.rb +0 -0
  89. data/{lib → leafy-rack/lib}/leafy/rack.rb +0 -0
  90. data/{lib → leafy-rack/lib}/leafy/rack/admin.rb +0 -0
  91. data/{lib → leafy-rack/lib}/leafy/rack/health.rb +0 -0
  92. data/{lib → leafy-rack/lib}/leafy/rack/instrumented.rb +0 -0
  93. data/{lib → leafy-rack/lib}/leafy/rack/metrics.rb +0 -0
  94. data/{lib → leafy-rack/lib}/leafy/rack/ping.rb +0 -0
  95. data/{lib → leafy-rack/lib}/leafy/rack/thread_dump.rb +0 -0
  96. data/{lib → leafy-rack/lib}/leafy/rack/version.rb +1 -1
  97. data/{spec → leafy-rack/spec}/admin_rack_spec.rb +0 -0
  98. data/{spec → leafy-rack/spec}/basic_instrumented_spec.rb +0 -0
  99. data/{spec → leafy-rack/spec}/health_rack_spec.rb +0 -0
  100. data/{spec → leafy-rack/spec}/health_writer_spec.rb +0 -0
  101. data/{spec → leafy-rack/spec}/instrumented_rack_spec.rb +0 -0
  102. data/{spec → leafy-rack/spec}/instrumented_spec.rb +0 -0
  103. data/{spec → leafy-rack/spec}/metrics_rack_spec.rb +0 -0
  104. data/{spec → leafy-rack/spec}/metrics_writer_spec.rb +0 -0
  105. data/{spec → leafy-rack/spec}/ping_rack_spec.rb +0 -0
  106. data/{spec → leafy-rack/spec}/setup.rb +0 -0
  107. data/{spec → leafy-rack/spec}/thread_dump_spec.rb +0 -0
  108. metadata +110 -34
@@ -0,0 +1,7 @@
1
+ # this is a generated file, to avoid over-writing it just delete this comment
2
+ require 'jar_dependencies'
3
+
4
+ require_jar( 'io.dropwizard.metrics', 'metrics-healthchecks', '3.1.0' )
5
+ require_jar( 'org.slf4j', 'slf4j-api', '1.7.7' )
6
+ require_jar( 'io.dropwizard.metrics', 'metrics-jvm', '3.1.0' )
7
+ require_jar( 'io.dropwizard.metrics', 'metrics-core', '3.1.0' )
@@ -0,0 +1,2 @@
1
+ require 'leafy-health_jars'
2
+ require 'leafy/health/registry'
@@ -0,0 +1,72 @@
1
+ require 'leafy/health'
2
+
3
+ # add json serialization definition
4
+ class com.codahale.metrics.health.HealthCheck::Result
5
+
6
+ attr_writer :data
7
+
8
+ def to_json( *args )
9
+ { :healthy => healthy?, :message => @data || message }.to_json( *args )
10
+ end
11
+ end
12
+
13
+ module Leafy
14
+ module Health
15
+ ThreadDeadlockHealthCheck = com.codahale.metrics.health.jvm.ThreadDeadlockHealthCheck
16
+ class HealthCheck < com.codahale.metrics.health.HealthCheck
17
+
18
+ def initialize( &block )
19
+ @block = block if block
20
+ end
21
+
22
+ # create healthy result object with given message
23
+ #
24
+ # param [String] optional result message, can be nil
25
+ # return [com.codahale.metrics.health.HealthCheck::Result]
26
+ def healthy( result = nil )
27
+ if result.is_a? Hash
28
+ r = com.codahale.metrics.health.HealthCheck::Result.healthy( result.to_json )
29
+ r.data = result
30
+ r
31
+ else
32
+ com.codahale.metrics.health.HealthCheck::Result.healthy( result )
33
+ end
34
+ end
35
+
36
+ # create unhealthy result object with given message
37
+ #
38
+ # param [String] result message
39
+ # return [com.codahale.metrics.health.HealthCheck::Result]
40
+ def unhealthy( result )
41
+ if result.is_a? Hash
42
+ r = com.codahale.metrics.health.HealthCheck::Result.unhealthy( result.to_json )
43
+ r.data = result
44
+ r
45
+ else
46
+ com.codahale.metrics.health.HealthCheck::Result.unhealthy( result )
47
+ end
48
+ end
49
+
50
+ def check
51
+ case result = call
52
+ when String
53
+ unhealthy( result )
54
+ when NilClass
55
+ healthy
56
+ when com.codahale.metrics.health.HealthCheck::Result
57
+ result
58
+ else
59
+ raise 'wrong result type'
60
+ end
61
+ end
62
+
63
+ def call
64
+ if @block
65
+ instance_eval( &@block )
66
+ else
67
+ 'health check "call" method not implemented'
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,55 @@
1
+ require 'leafy/health'
2
+ require 'leafy/health/health_check'
3
+ module Leafy
4
+ module Health
5
+ class Registry
6
+
7
+ # state ofthe registry
8
+ attr_reader :health
9
+
10
+ def initialize
11
+ @health = com.codahale.metrics.health.HealthCheckRegistry.new
12
+ end
13
+
14
+ # register a HealthCheck under a given name
15
+ #
16
+ # @param [String] name
17
+ # @param [String] instead of block any check object which responds to 'call'
18
+ # @yieldparam [HealthCheckRegistry::HealthCheck] which has convienient methods to create healthy and unhealthy results with message
19
+ # @yieldreturn [String] if the healthcheck fails return the message
20
+ # @yieldreturn [NilClass] if the healthcheck succeeds
21
+ # @yieldreturn [com.codahale.metrics.health.HealthCheck::Result] if the check produces its own result object
22
+ def register(name, check = nil, &block )
23
+ if check and not block_given? and check.is_a? com.codahale.metrics.health.HealthCheck
24
+ @health.register( name, check )
25
+ elsif check.nil? and block_given?
26
+ @health.register( name, HealthCheck.new( &block ) )
27
+ else
28
+ raise 'needs either a block and object with call method'
29
+ end
30
+ end
31
+
32
+ # unregister a HealthCheck for a given name
33
+ #
34
+ # @param [String] name
35
+ def unregister(name)
36
+ @health.unregister(name)
37
+ end
38
+
39
+ # the names of all registered HealthCheck
40
+ #
41
+ # @return [Array<String>] names of HealthCheck in order of their registration
42
+ def names
43
+ @health.names.to_a
44
+ end
45
+
46
+ # # run a healthcheck for a given name
47
+ # #
48
+ # # @param [String] name
49
+ # # @return [Java::ComCodahaleMetricsHealth::HealthCheck::Result] result of the health-check
50
+ # def run_health_check(name)
51
+ # @health.runHealthCheck(name)
52
+ # end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,6 @@
1
+ module Leafy
2
+ module Health
3
+ VERSION = '0.3.1'.freeze
4
+ end
5
+ end
6
+
@@ -0,0 +1,164 @@
1
+ require 'leafy/health'
2
+ require 'json'
3
+
4
+ describe Leafy::Health::Registry do
5
+
6
+ subject { Leafy::Health::Registry.new }
7
+
8
+ it 'has thread-deadlock-health-check' do
9
+ subject.register( 'app', Leafy::Health::ThreadDeadlockHealthCheck.new )
10
+
11
+ expect(subject.names).to eq ['app']
12
+ end
13
+
14
+ it 'registers and unregister check as block' do
15
+ subject.register('me') do
16
+ 'error'
17
+ end
18
+ expect(subject.names).to eq ['me']
19
+
20
+ results = subject.health.run_health_checks
21
+ expect(results.keys).to eq ['me']
22
+
23
+ first = results.values.to_array.first
24
+ expect(first.message).to eq 'error'
25
+ expect(first.healthy?).to eq false
26
+
27
+ subject.unregister('me')
28
+ expect(subject.names).to be_empty
29
+ end
30
+
31
+ it 'registers and unregister check as block using dsl' do
32
+ subject.register('me') do
33
+ healthy 'ok'
34
+ end
35
+ expect(subject.names).to eq ['me']
36
+
37
+ results = subject.health.run_health_checks
38
+ expect(results.keys).to eq ['me']
39
+
40
+ first = results.values.to_array.first
41
+ expect(first.message).to eq 'ok'
42
+ expect(first.healthy?).to eq true
43
+
44
+ subject.unregister('me')
45
+ expect(subject.names).to be_empty
46
+ end
47
+
48
+ it 'registers and unregister check as HealthCheck with block' do
49
+ subject.register('me', Leafy::Health::HealthCheck.new {} )
50
+
51
+ expect(subject.names).to eq ['me']
52
+
53
+ results = subject.health.run_health_checks
54
+ expect(results.keys).to eq ['me']
55
+
56
+ first = results.values.to_array.first
57
+ expect(first.message).to be_nil
58
+ expect(first.healthy?).to eq true
59
+
60
+ subject.unregister('me')
61
+ expect(subject.names).to be_empty
62
+ end
63
+
64
+ it 'registers and unregister check as HealthCheck without implementing call' do
65
+ subject.register('me', Leafy::Health::HealthCheck.new )
66
+
67
+ expect(subject.names).to eq ['me']
68
+
69
+ results = subject.health.run_health_checks
70
+ expect(results.keys).to eq ['me']
71
+
72
+ first = results.values.to_array.first
73
+ expect(first.message).to eq 'health check "call" method not implemented'
74
+ expect(first.healthy?).to eq false
75
+
76
+ subject.unregister('me')
77
+ expect(subject.names).to be_empty
78
+ end
79
+
80
+ it 'fails register check as wrong object' do
81
+ expect { subject.register('me', Object.new ) }.to raise_error
82
+ end
83
+
84
+ describe Leafy::Health::HealthCheck do
85
+
86
+ it 'is healthy default with simple block' do
87
+ check = Leafy::Health::HealthCheck.new do
88
+ nil
89
+ end
90
+ expect( check.check.healthy? ).to be true
91
+ expect( check.check.message ).to be nil
92
+ expect( check.check.to_json ).to eq "{\"healthy\":true,\"message\":null}"
93
+ end
94
+
95
+ it 'is healthy with simple block' do
96
+ check = Leafy::Health::HealthCheck.new do
97
+ healthy 'happy'
98
+ end
99
+ expect( check.check.healthy? ).to be true
100
+ expect( check.check.message ).to eq 'happy'
101
+ expect( check.check.to_json ).to eq "{\"healthy\":true,\"message\":\"happy\"}"
102
+ end
103
+
104
+ it 'is healthy with structural message' do
105
+ check = Leafy::Health::HealthCheck.new do
106
+ healthy :msg => 'happy', :date => '11-11-2011'
107
+ end
108
+ expect( check.check.healthy? ).to be true
109
+ expect( check.check.to_json ).to eq "{\"healthy\":true,\"message\":{\"msg\":\"happy\",\"date\":\"11-11-2011\"}}"
110
+ end
111
+
112
+ it 'is healthy default' do
113
+ check = Leafy::Health::HealthCheck.new
114
+ def check.call; nil; end
115
+ expect( check.check.healthy? ).to be true
116
+ expect( check.check.message ).to eq nil
117
+ end
118
+
119
+ it 'is healthy' do
120
+ check = Leafy::Health::HealthCheck.new
121
+ def check.call; healthy( 'ok' ); end
122
+ expect( check.check.healthy? ).to be true
123
+ expect( check.check.message ).to eq 'ok'
124
+ end
125
+
126
+ it 'is unhealthy default with simple block' do
127
+ check = Leafy::Health::HealthCheck.new do
128
+ 'sick'
129
+ end
130
+ expect( check.check.healthy? ).to be false
131
+ expect( check.check.message ).to eq 'sick'
132
+ end
133
+
134
+ it 'is unhealthy with simple block' do
135
+ check = Leafy::Health::HealthCheck.new do
136
+ unhealthy 'really sick'
137
+ end
138
+ expect( check.check.healthy? ).to be false
139
+ expect( check.check.message ).to eq 'really sick'
140
+ end
141
+
142
+ it 'is unhealthy with structural message' do
143
+ check = Leafy::Health::HealthCheck.new do
144
+ unhealthy :msg => 'oh je', :date => '11-11-2011'
145
+ end
146
+ expect( check.check.healthy? ).to be false
147
+ expect( check.check.to_json ).to eq "{\"healthy\":false,\"message\":{\"msg\":\"oh je\",\"date\":\"11-11-2011\"}}"
148
+ end
149
+
150
+ it 'is unhealthy default' do
151
+ check = Leafy::Health::HealthCheck.new
152
+ def check.call; 'not ok'; end
153
+ expect( check.check.healthy? ).to be false
154
+ expect( check.check.message ).to eq 'not ok'
155
+ end
156
+
157
+ it 'is unhealthy' do
158
+ check = Leafy::Health::HealthCheck.new
159
+ def check.call; unhealthy( 'not ok' ); end
160
+ expect( check.check.healthy? ).to be false
161
+ expect( check.check.message ).to eq 'not ok'
162
+ end
163
+ end
164
+ end
@@ -0,0 +1 @@
1
+ $LOAD_PATH.unshift File.expand_path( '../../lib', __FILE__ )
@@ -0,0 +1,5 @@
1
+ .yardoc
2
+ doc
3
+ pkg
4
+ *.lock
5
+ logs
@@ -0,0 +1,9 @@
1
+ #-*- mode: ruby -*-
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ gem 'leafy-metrics', :path => '../leafy-metrics'
8
+
9
+ # vim: syntax=Ruby
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Lookout
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,174 @@
1
+ # Leafy-Logger
2
+
3
+ ## installation
4
+
5
+ via rubygems
6
+ ```
7
+ gem install leafy-logger
8
+ ```
9
+ or add to your Gemfile
10
+ ```
11
+ gem 'leafy-logger
12
+ ```
13
+
14
+ installing the gem also takes care of the jar dependencies with jruby-1.7.16+
15
+
16
+ ## usage
17
+
18
+ default configuration
19
+ ```
20
+ require 'leafy/logger/factory'
21
+ require 'leafy/metrics/registry'
22
+
23
+ f = Leafy::Logger::Factory.new
24
+ f.configure( Leafy::Metrics::Registry.new, 'application' )
25
+
26
+ l = Leafy::Logger::Factory.get_logger 'my.app'
27
+ ```
28
+
29
+ the configure will setup the (default) appenders and register the metrics.
30
+
31
+ there are more configurations for the logger Factory
32
+ ```
33
+ require 'leafy/logger/appender_factories'
34
+
35
+ f.level = 'INFO'
36
+ f.loggers 'my.app' => 'WARN', 'my' => 'DEBUG'
37
+ f.appenders( Leafy::Logger::ConsoleAppenderFactory.new,
38
+ Leafy::Logger::FileAppenderFactory.new('log/my.log' ) )
39
+ f[ 'my.db' ] = 'INFO'
40
+ ```
41
+
42
+ after the logger factory was configured once, any change of the log levels will result in a reconfiguration.
43
+
44
+ ## appender factories
45
+
46
+ all appender factories have common set of attributes:
47
+ ```
48
+ appender = Leafy::Logger::ConsoleAppenderFactory.new do
49
+ # :off, :trace, :debug, :info, :warn, :error, :all
50
+ self.threshold = :debug # default :all
51
+ self.log_format = "%-5p [%d{ISO8601,UTC}] %c: %m%n%ex"
52
+ self.queue_size = 1024 # default 256
53
+ # means nothing gets discarded
54
+ self.discarding_threshold = 0 # default -1
55
+ end
56
+ ```
57
+
58
+ ### console appender factory
59
+
60
+ ```
61
+ appender = Leafy::Logger::ConsoleAppenderFactory.new do
62
+ self.target 'STDOUT' # default is 'STDERR'
63
+ end
64
+ ```
65
+
66
+ ### syslog appender factory
67
+
68
+ ```
69
+ appender = Leafy::Logger::SyslogAppenderFactory.new do
70
+ self.host = '127.0.0.1' # default localhost
71
+ self.port = 514 # default 514
72
+ self.include_stack_trace = false # default true
73
+ # see Leafy::Logger::SyslogAppenderFactory.all_facilities
74
+ self.facility = :auth # default :local0
75
+ self.stack_trace_prefix = '__' # default '!'
76
+ end
77
+ ```
78
+
79
+ ### file appender factory
80
+
81
+ without archived files
82
+
83
+ ```
84
+ appender = Leafy::Logger::SyslogAppenderFactory.new( 'logs/app.log' )
85
+ ```
86
+
87
+ or
88
+
89
+ ```
90
+ appender = Leafy::Logger::SyslogAppenderFactory.new do
91
+ self.current_log_filename = 'logs/app.log'
92
+ end
93
+ ```
94
+
95
+ with archived files
96
+
97
+ ```
98
+ appender = Leafy::Logger::SyslogAppenderFactory.new do
99
+ self.current_log_filename = 'logs/app.log'
100
+ self.archive = true # default true
101
+ # files ending with .gz or .zip will packed respectively
102
+ self.archived_log_filename_pattern = 'logs/app-%d.log'
103
+ self.archived_file_count = 10 # default 5
104
+ end
105
+ ```
106
+
107
+ # using configurations
108
+
109
+ a yaml file or an options hash can be used to configure the logger factory. once you have a logger factory you can reconfigure it with a yaml-file or options hash at runtime.
110
+
111
+ ## build logger factory from yaml file
112
+
113
+ having a yaml file like (config/logging.yaml)
114
+
115
+ ```
116
+ level: ERROR
117
+ loggers:
118
+ com.example.app: DEBUG
119
+ com.example.db: INFO
120
+ appenders:
121
+ - type: console
122
+ threshold: DEBUG
123
+ target: STDERR
124
+ - type: file
125
+ threshold: INFO
126
+ currentLogFilename: ./logs/example.log
127
+ archivedLogFilenamePattern: ./logs/example-%d.log.gz
128
+ archivedFileCount: 12
129
+ - type: syslog
130
+ host: 127.0.0.1
131
+ port: 123
132
+ facility: KERN
133
+ ```
134
+ can be used to build ```LoggerFactory``` directly from this yaml file:
135
+
136
+ ```
137
+ factory = Leafy::Logger::Factory.new_from_yaml( 'config/logging.yaml' )
138
+ ```
139
+
140
+ having the same config as ```Hash``` can be used as well
141
+
142
+ ```
143
+ options = YAML.load( File.read( 'config/logging.yaml' ) )
144
+ factory = Leafy::Logger::Factory.new_from_options( options )
145
+ ```
146
+
147
+ ## reconfigure logger factory at runtime
148
+
149
+ ```
150
+ factory.reconfigure_from_yaml( 'config/logging.yaml' )
151
+ ```
152
+
153
+ or
154
+
155
+ ```
156
+ factory.reconfigure_from_options( options )
157
+ ```
158
+
159
+ ## developement
160
+
161
+ get all the gems and jars in place
162
+
163
+ gem install jar-dependencies --development
164
+ bundle install
165
+
166
+ please make sure you are using jar-dependencies >= 0.1.8 !
167
+
168
+ for running all specs
169
+
170
+ rake
171
+
172
+ or a single one
173
+
174
+ rspec spec/reporter_spec.rb