picklive-logging 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in picklive-logging.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ require "picklive/logging"
@@ -0,0 +1,33 @@
1
+ require 'logger'
2
+
3
+ module Picklive
4
+ class Logger < ::Logger
5
+ def initialize io, name
6
+ super io
7
+ @name = name
8
+ end
9
+
10
+ def format_message severity, timestamp, progname, message
11
+ Picklive::Logger::Factory.log_format % [ Process.pid, Thread.current.object_id, severity, @name, message, Time.now ]
12
+ end
13
+
14
+
15
+ class Factory
16
+ class << self
17
+ attr_accessor :initial_log_level
18
+ attr_accessor :log_format
19
+ end
20
+ self.initial_log_level ||= ::Logger::INFO
21
+ self.log_format ||= "%1$5.5s | %2$10.10s | %3$-5.5s | %4$-25.25s | %5$s\n"
22
+
23
+
24
+ def self.build name
25
+ logger = Picklive::Logger.new STDOUT, name
26
+ logger.level = Picklive::Logger::Factory.initial_log_level
27
+ logger
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+
@@ -0,0 +1,27 @@
1
+ module Picklive
2
+ # Summary
3
+ #
4
+ # - Picklive::Logging - module, you include this to a class where you want logging
5
+ # - Picklive::Logger - subclass of ruby's Logger, access it via `logger` in a class where you included Picklive::Logging
6
+ # - Picklive::Logger::Factory - used by Picklive::Logging to create a Logger object
7
+ # - you can set `initial_log_level` or `log_format`
8
+ module Logging
9
+ def self.included base
10
+ base.class_eval do
11
+ class << self
12
+ attr_accessor :logger
13
+ end
14
+
15
+ def self.logger
16
+ @logger ||= Picklive::Logger::Factory.build name
17
+ end
18
+
19
+ def logger
20
+ self.class.logger
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ end
27
+
@@ -0,0 +1,6 @@
1
+ module Picklive
2
+ autoload :Logging, 'picklive/logging'
3
+ autoload :Logger, 'picklive/logger'
4
+ autoload :NullLogger, 'picklive/null_logger'
5
+ end
6
+
@@ -0,0 +1,12 @@
1
+ require 'logger'
2
+
3
+ module Picklive
4
+ class NullLogger < ::Logger
5
+ def initialize
6
+ end
7
+
8
+ def add *argv, &block
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ require "picklive/logging/autoload"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "picklive-logging"
8
+ s.version = "1.0.0"
9
+ s.authors = ["Craig Webster", "Levente Bagi"]
10
+ s.email = ["levente@picklive.com"]
11
+ s.homepage = "http://tech.picklive.com"
12
+ s.summary = %q{Picklive Logging}
13
+ s.description = %q{A mix-in that provides a logger object}
14
+
15
+ s.rubyforge_project = "picklive-logging"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ # specify any dependencies here; for example:
23
+ # s.add_development_dependency "rspec"
24
+ # s.add_runtime_dependency "rest-client"
25
+ end
26
+
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: picklive-logging
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Craig Webster
14
+ - Levente Bagi
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2012-02-14 00:00:00 Z
20
+ dependencies: []
21
+
22
+ description: A mix-in that provides a logger object
23
+ email:
24
+ - levente@picklive.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - Gemfile
33
+ - Rakefile
34
+ - lib/picklive-logging.rb
35
+ - lib/picklive/logger.rb
36
+ - lib/picklive/logging.rb
37
+ - lib/picklive/logging/autoload.rb
38
+ - lib/picklive/null_logger.rb
39
+ - picklive-logging.gemspec
40
+ homepage: http://tech.picklive.com
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project: picklive-logging
69
+ rubygems_version: 1.8.10
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Picklive Logging
73
+ test_files: []
74
+