super_logger 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 750432fafde32eb25108d8cf1adaa984f789cded
4
+ data.tar.gz: 84a4882561d56918946817ed8929b2bc3e31a214
5
+ SHA512:
6
+ metadata.gz: 57f2377eba282826f33e32ef11388ff306b60a7a4bb1ec7ea707aafea0e942b71d62d207cc1b3a527c2c70067b10e2e2d7b03f5e6c2a35bfb309e6fec9061664
7
+ data.tar.gz: dde89c258e74dace9c72a69c67f8076be828844587b9980ecb259afc4d920d64d2f5548f369e494d63a06b56dfb868b56d128dd508c488ca28a9adea07e14ede
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in super_logger.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Matt Dodds
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # SuperLogger
2
+
3
+ Originally was going to be called "LogBomb". Just provides a very easy way to find debug messages in a log.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'super_logger'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install super_logger
20
+
21
+ ## Configuration
22
+
23
+ Shown with default values:
24
+
25
+ ```ruby
26
+ Configuration.configure do |config|
27
+ config.delimiter = "\n"
28
+ config.line_length = 50
29
+ config.rule_character = '='
30
+ config.log_path = './default.log'
31
+ config.logger = Logger.new(log_path) # Rails.logger
32
+ end
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ```ruby
38
+ SuperLogger.log('This is a log message', 'Key')
39
+ ```
40
+
41
+ See [example.log](http://github.com/MatthewRDodds/super_logger/blob/master/example.log) for examples of that this looks like in the log.
42
+
43
+ ## Development
44
+
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it ( https://github.com/[my-github-username]/super_logger/fork )
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "super_logger"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/example.log ADDED
@@ -0,0 +1,25 @@
1
+ I, [2015-04-24T22:18:06.581794 #42823] INFO -- : ==================================================
2
+ I, [2015-04-24T22:18:06.581866 #42823] INFO -- : ==================== An Array ====================
3
+ I, [2015-04-24T22:18:06.581888 #42823] INFO -- : ==================================================
4
+ I, [2015-04-24T22:18:06.581907 #42823] INFO -- : This is a message
5
+ I, [2015-04-24T22:18:06.581924 #42823] INFO -- : this is another message
6
+ I, [2015-04-24T22:18:06.581942 #42823] INFO -- : ==================================================
7
+ I, [2015-04-24T22:18:06.581958 #42823] INFO -- : ==================================================
8
+ I, [2015-04-24T22:18:06.581975 #42823] INFO -- : ==================================================
9
+ I, [2015-04-24T22:18:06.581996 #42823] INFO -- :
10
+ I, [2015-04-24T22:18:24.436987 #42823] INFO -- : ==================================================
11
+ I, [2015-04-24T22:18:24.437035 #42823] INFO -- : ==================== A String ====================
12
+ I, [2015-04-24T22:18:24.437055 #42823] INFO -- : ==================================================
13
+ I, [2015-04-24T22:18:24.437078 #42823] INFO -- : This is a message
14
+ I, [2015-04-24T22:18:24.437097 #42823] INFO -- : ==================================================
15
+ I, [2015-04-24T22:18:24.437114 #42823] INFO -- : ==================================================
16
+ I, [2015-04-24T22:18:24.437130 #42823] INFO -- : ==================================================
17
+ I, [2015-04-24T22:18:24.437148 #42823] INFO -- :
18
+ I, [2015-04-24T22:18:51.973567 #42823] INFO -- : ==================================================
19
+ I, [2015-04-24T22:18:51.973625 #42823] INFO -- : ===================== A Hash =====================
20
+ I, [2015-04-24T22:18:51.973651 #42823] INFO -- : ==================================================
21
+ I, [2015-04-24T22:18:51.975979 #42823] INFO -- : key: value
22
+ I, [2015-04-24T22:18:51.976019 #42823] INFO -- : ==================================================
23
+ I, [2015-04-24T22:18:51.976043 #42823] INFO -- : ==================================================
24
+ I, [2015-04-24T22:18:51.976065 #42823] INFO -- : ==================================================
25
+ I, [2015-04-24T22:18:51.976094 #42823] INFO -- :
@@ -0,0 +1,7 @@
1
+ require 'super_logger/version'
2
+ require 'logger'
3
+
4
+ require 'super_logger/configuration'
5
+
6
+ require 'super_logger/message_formatter'
7
+ require 'super_logger/base_logger'
@@ -0,0 +1,39 @@
1
+ module SuperLogger
2
+ def self.conf
3
+ SuperLogger.config
4
+ end
5
+
6
+ def self.base_line
7
+ @line ||= conf.rule_character * conf.line_length
8
+ end
9
+
10
+ def self.log(loggable, key = nil, log_level = 'info')
11
+ horizontal_rule(log_level, key)
12
+
13
+ MessageFormatter.format(loggable).each do |message|
14
+ actual_log message, log_level
15
+ end
16
+
17
+ horizontal_rule(log_level)
18
+ end
19
+
20
+ def self.actual_log(message, log_level)
21
+ conf.logger.send(log_level, message)
22
+ end
23
+
24
+ def self.rule_with_text(key)
25
+ computed_length = base_line.length - (key.length + 2)
26
+ partial_line = conf.rule_character * (computed_length / 2).floor
27
+
28
+ "#{partial_line} #{key} #{partial_line}"
29
+ end
30
+
31
+ def self.horizontal_rule(log_level, key = nil)
32
+ middle_line = key ? rule_with_text(key) : base_line
33
+
34
+ actual_log(base_line, log_level)
35
+ actual_log(middle_line, log_level)
36
+ actual_log(base_line, log_level)
37
+ actual_log(String.new, log_level) unless key
38
+ end
39
+ end
@@ -0,0 +1,25 @@
1
+ module SuperLogger
2
+ class Configuration
3
+ attr_accessor :delimiter, :line_length, :rule_character, :log_path, :logger
4
+
5
+ def initialize
6
+ @delimiter = "\n"
7
+ @line_length = 50
8
+ @rule_character = '='
9
+ @log_path = './default.log'
10
+ @logger = Logger.new(log_path)
11
+ end
12
+ end
13
+
14
+ class << self
15
+ attr_writer :config
16
+
17
+ def config
18
+ @config ||= Configuration.new
19
+ end
20
+
21
+ def configure
22
+ yield(config)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ module SuperLogger
2
+ module MessageFormatter
3
+ def self.format(message)
4
+ case message
5
+ when Hash
6
+ message.map { |k, v| "#{k}: #{v}" }
7
+ when Array
8
+ message
9
+ else
10
+ message.split SuperLogger.config.delimiter
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module SuperLogger
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'super_logger/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'super_logger'
8
+ spec.version = SuperLogger::VERSION
9
+ spec.authors = ['Matthew Dodds']
10
+ spec.email = ['matthewrusselldodds@gmail.com']
11
+
12
+ spec.summary = %q{Log bomber}
13
+ spec.description = %q{Writes a message with a logger that can easily be found in the log}
14
+ spec.homepage = 'http://github.com/MatthewRDodds/super_logger'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.9'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'pry', '~> 0.10'
25
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: super_logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Dodds
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.10'
55
+ description: Writes a message with a logger that can easily be found in the log
56
+ email:
57
+ - matthewrusselldodds@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - example.log
70
+ - lib/super_logger.rb
71
+ - lib/super_logger/base_logger.rb
72
+ - lib/super_logger/configuration.rb
73
+ - lib/super_logger/message_formatter.rb
74
+ - lib/super_logger/version.rb
75
+ - super_logger.gemspec
76
+ homepage: http://github.com/MatthewRDodds/super_logger
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.4.5
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Log bomber
100
+ test_files: []