mallard-logger 1.0.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 +15 -0
- data/lib/mallard-logger.rb +1 -0
- data/lib/mallard/logger.rb +28 -0
- metadata +45 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
MGY1ZGUyOGViNzY4NmNmZjI3NjliNGE4NGU5NjNkNzdmZTdkZWM3MQ==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
YzY3ZjNjMmZhYTNiNjE2OWE2MGZhOGZiNjk4YTJlNDYwNDg1ZGZiNA==
|
|
7
|
+
SHA512:
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
YmU5ZTgzYzVjMjgwZDBjMjk1YzFiNTYxZmRmZmZiMDEwZTEyYjRlMjkwMmM3
|
|
10
|
+
ZjkxNGYzZmQyYzk1NzUyYjBmZDk5NGIyZWJhZTI1YmE2NDNkZWY5NjUyYzY1
|
|
11
|
+
MjQ4N2VkMDE2MGNlZWVmNTFkMmQzNDQ3OTM4NWZiNGQwNjM1MjQ=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
YzY5NmNkZDUwYzdiYjFiMWY3MDI0YmM3Mjk4MWUwMTc0ZDNjYzUxZDY4NWUx
|
|
14
|
+
NTVlMTUzMWRkNGY2N2Q5M2Q4YzM1YmRmMTNmZGE1M2Q0NTllMGM3MWY3ZTMw
|
|
15
|
+
NmRkNDY4ZjNlYjM3MDI4YjdlOTFiNzQ1YzRhMzY2MjNkYjNiYzU=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'mallard/logger'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'logger'
|
|
2
|
+
require 'socket'
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
# a simple wrapper for the Logger class.
|
|
6
|
+
# Mallard::Logger does the following for you:
|
|
7
|
+
# * prepends $HOME/logs to the path
|
|
8
|
+
# * creates the directory if it does not already exist
|
|
9
|
+
# * sets logfile rotation to daily
|
|
10
|
+
# * sets date format to CCYY-MM-DD hh:mm:ss
|
|
11
|
+
module Mallard; class Logger < ::Logger
|
|
12
|
+
@@prefix = "#{ENV['HOME']}/logs"
|
|
13
|
+
def initialize (logfile)
|
|
14
|
+
full = "#{@@prefix}/#{logfile}"
|
|
15
|
+
dir = File.dirname(full)
|
|
16
|
+
@host = Socket.gethostname.split(/\./).first
|
|
17
|
+
begin
|
|
18
|
+
FileUtils.mkpath(dir) unless test(?d, dir)
|
|
19
|
+
super("#{@@prefix}/#{logfile}", 'daily')
|
|
20
|
+
rescue Errno::EACCES
|
|
21
|
+
Kernel.warn "Permission to create/access log denied. Logging to stderr."
|
|
22
|
+
super(STDERR)
|
|
23
|
+
end
|
|
24
|
+
self.formatter = proc do |severity, datetime, progname, msg|
|
|
25
|
+
"#{severity[0]}, [#{datetime.strftime("%F %T")}##{@host}:#{$$}] #{severity} -- : #{msg}\n"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end; end
|
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mallard-logger
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Angry Duck
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Simple wrapper around Logger to behave a specific way
|
|
14
|
+
email: angry.canard@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/mallard-logger.rb
|
|
20
|
+
- lib/mallard/logger.rb
|
|
21
|
+
homepage: http://rubygems.org/gems/mallard-logger
|
|
22
|
+
licenses:
|
|
23
|
+
- GPLv2
|
|
24
|
+
metadata: {}
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ! '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ! '>='
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubyforge_project:
|
|
41
|
+
rubygems_version: 2.1.11
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: logging package
|
|
45
|
+
test_files: []
|