footprint-log 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16e9a0ab8e49d29636aeb605dd7d00ef1fbf3acb
4
- data.tar.gz: f4190272a1e0004f7bf69576f9811b62e6854473
3
+ metadata.gz: 4848d46a5d4b1bcea985f3421eaca78df8c57ede
4
+ data.tar.gz: 7feb5f3a3a136ba103ed951709c446e284edee85
5
5
  SHA512:
6
- metadata.gz: df4b20166ee7ae7f01ae130c8f5eee0aa0aa63aac080ff7905128a09b1f5933070dc24e818a398ac140b5808cf01a011233d0f23fe41a3b01952b57194962fd3
7
- data.tar.gz: fff6a86deba84a232a3d9fcbe7fe2d9b958d7646914e9de4547648919f2ffdd0374672cdec3f93da9197fcd58a52075ce9a64975d50d8097fb6e363b0dcb1334
6
+ metadata.gz: 54d1c47b19db6adfccdc5fd5395a506221415b5b171efdc3e0dfd597bf9f03ec91d7711235523d8c7fcf6ea2efa7131972eb05b84f0a694f6e829c8004a572b2
7
+ data.tar.gz: b6b2d6063e95fd804f4935f636512bf83d43a8d1c64bf99f66cf7eb57653044d7fc335eca67ad93369a53b0336b83fa7793ce987d6b9d15151402fb5adcbbb24
data/lib/footprint.rb CHANGED
@@ -1,9 +1,9 @@
1
- require_relative 'footprint/log'
2
-
3
- module Footprint
1
+ #
2
+ # Module that wraps the Footprint gem content.
3
+ #
4
+ module Footprint; end
4
5
 
5
- attr_accessor :logger
6
-
7
- end
6
+ require_relative 'footprint/log'
7
+ require_relative 'footprint/middleware'
8
8
 
9
9
 
data/lib/footprint/log.rb CHANGED
@@ -1,3 +1,12 @@
1
+ module Footprint
2
+
3
+ #
4
+ # Module that wraps the Footprint Loggers content.
5
+ #
6
+ module Log; end
7
+
8
+ end
9
+
1
10
  require_relative 'log/basic'
2
11
  require_relative 'log/error_file'
3
12
  require_relative 'log/out_file'
@@ -4,8 +4,14 @@ module Footprint
4
4
 
5
5
  module Log
6
6
 
7
+ # Class that extends the Ruby Logger.
8
+ #
9
+ # Does nothing extra for now but will be used to add generic
10
+ # configuration in the future since other Footprint::Log
11
+ # classes extend this.
7
12
  class Basic < Logger
8
13
 
14
+ # Sets the default logdev as nil
9
15
  def initialize logdev = nil, shift_age = 0, shift_size = 1048576
10
16
  super
11
17
  end
@@ -4,8 +4,14 @@ module Footprint
4
4
 
5
5
  module Log
6
6
 
7
+ # Class that extends the Footprint::Log::Basic and
8
+ # adds a write method which logs on error level.
9
+ #
10
+ # This Class can be used as a File instance to
11
+ # write in log.
7
12
  class ErrorFile < Basic
8
13
 
14
+ # Logs the message on error level on logger.
9
15
  def write(message)
10
16
  error message
11
17
  end
@@ -4,6 +4,11 @@ module Footprint
4
4
 
5
5
  module Log
6
6
 
7
+ # Class that extends the GELF::Logger.
8
+ #
9
+ # Does nothing extra for now but will be used to add generic
10
+ # configuration in the future since other Footprint::Log
11
+ # classes will extend this.
7
12
  class Gelf < GELF::Logger
8
13
 
9
14
  end
@@ -4,8 +4,14 @@ module Footprint
4
4
 
5
5
  module Log
6
6
 
7
+ # Class that extends the Footprint::Log::Basic and
8
+ # adds a write method which logs on info level.
9
+ #
10
+ # This Class can be used as a File instance to
11
+ # write in log.
7
12
  class OutFile < Basic
8
13
 
14
+ # Logs the message on info level on logger.
9
15
  def write(message)
10
16
  info message
11
17
  end
@@ -1 +1,10 @@
1
+ module Footprint
2
+
3
+ #
4
+ # Module that wraps the Footprint Middleware content.
5
+ #
6
+ module Middleware; end
7
+
8
+ end
9
+
1
10
  require_relative 'middleware/logger'
@@ -3,10 +3,25 @@ require_relative '../log'
3
3
 
4
4
  module Footprint
5
5
 
6
+ #
7
+ # Class that is actually the Middleware we use to decorate
8
+ # the application with loggers, taking advantage of the @env.
9
+ #
6
10
  class Middleware
7
11
 
12
+ # @app = the instance of the application that uses this middleware.
13
+ # @logger = the instance of the logger used to decorate the Rack application.
8
14
  attr_accessor :app, :logger
9
15
 
16
+ # Initialize the Middleware with the app that uses this
17
+ # Middleware and an optional block.
18
+ #
19
+ # Sets as the default logger a Footprint::Log::Basic on STDOUT.
20
+ #
21
+ # Decorate the given app with a new method called logger,
22
+ # that will return the instance of the logger from the env.
23
+ #
24
+ # If any block is given, a instance_eval is called.
10
25
  def initialize(app, &block)
11
26
 
12
27
  @app = app
@@ -21,11 +36,19 @@ module Footprint
21
36
  self.instance_eval &block if block
22
37
  end
23
38
 
39
+
40
+ # The current instance of the logger is set on env[:footprint_logger]
41
+ # and the app is called further with the enriched env.
24
42
  def call(env)
25
43
  env[:footprint_logger] = @logger
26
44
  @app.call env
27
45
  end
28
46
 
47
+ # Initialize the current instance of the logger with
48
+ # a new instance of the class given as parameter.
49
+ #
50
+ # The initialization of the class given is done using
51
+ # the second parameter.
29
52
  def set clazz, *args
30
53
  @logger = clazz.send(:new, *args)
31
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: footprint-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puiu Ionut