meow-logger 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +13 -0
- data/Rakefile +1 -0
- data/lib/meow-logger.rb +2 -0
- data/lib/meow-logger/rails.rb +37 -0
- data/lib/meow-logger/rails3.rb +12 -0
- data/lib/meow-logger/railtie.rb +11 -0
- data/lib/meow-logger/version.rb +5 -0
- data/meow-logger.gemspec +19 -0
- metadata +56 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Kristjan Rang
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/meow-logger.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Meow
|
2
|
+
module Logger
|
3
|
+
class Formatter
|
4
|
+
SEVERITY_TO_COLOR_MAP =
|
5
|
+
{ 'DEBUG'=>'0;37',
|
6
|
+
'INFO'=>'32',
|
7
|
+
'WARN'=>'33',
|
8
|
+
'ERROR'=>'31',
|
9
|
+
'FATAL'=>'31',
|
10
|
+
'UNKNOWN'=>'37'}
|
11
|
+
|
12
|
+
def call(severity, time, progname, msg)
|
13
|
+
formatted_severity = sprintf("%-5s","#{severity}")
|
14
|
+
|
15
|
+
formatted_time =
|
16
|
+
time.strftime("%Y-%m-%d %H:%M:%S.") << time.usec.to_s[0..2].rjust(3)
|
17
|
+
|
18
|
+
color = SEVERITY_TO_COLOR_MAP[severity]
|
19
|
+
|
20
|
+
"\033[0;37m#{formatted_time}\033[0m [\033[#{color}m#{formatted_severity}\033[0m] #{msg.strip} (pid:#{$$})\n"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Rails
|
25
|
+
def self.stdout_logger
|
26
|
+
logger = Logger.new(STDOUT)
|
27
|
+
logger.level = Logger.const_get(([ENV['LOG_LEVEL'].to_s.upcase, "INFO"] & %w[DEBUG INFO WARN ERROR FATAL UNKNOWN]).compact.first)
|
28
|
+
logger.formatter = Formatter.new
|
29
|
+
logger
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.set_logger
|
33
|
+
STDOUT.sync = true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/meow-logger.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'meow-logger/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "meow-logger"
|
8
|
+
gem.version = Meow::Logger::VERSION
|
9
|
+
gem.authors = ["Kristjan Rang"]
|
10
|
+
gem.email = ["mail@kristjanrang.eu"]
|
11
|
+
gem.description = %q{Custom Rails logger to stdout}
|
12
|
+
gem.summary = %q{Overrides Rails' built in logger to send all logs to stdout with colors}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: meow-logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kristjan Rang
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-27 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Custom Rails logger to stdout
|
15
|
+
email:
|
16
|
+
- mail@kristjanrang.eu
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- lib/meow-logger.rb
|
27
|
+
- lib/meow-logger/rails.rb
|
28
|
+
- lib/meow-logger/rails3.rb
|
29
|
+
- lib/meow-logger/railtie.rb
|
30
|
+
- lib/meow-logger/version.rb
|
31
|
+
- meow-logger.gemspec
|
32
|
+
homepage: ''
|
33
|
+
licenses: []
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
none: false
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
none: false
|
50
|
+
requirements: []
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.8.23
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: Overrides Rails' built in logger to send all logs to stdout with colors
|
56
|
+
test_files: []
|