zlogs 0.1

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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in zlogs.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 ev42
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.
@@ -0,0 +1,29 @@
1
+ # Zlogs
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'zlogs'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install zlogs
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,89 @@
1
+ #encoding: utf-8
2
+ require "zlogs/version"
3
+ require 'logger'
4
+
5
+ module ZLogs
6
+ ##
7
+ # Инициализация логера с appname в logfile
8
+ #
9
+ def self.app_logger_init(appname, logfile)
10
+ nlog=Logger.new(logfile)
11
+ nlog.progname=appname
12
+ #nlog.filename=logfile
13
+ set_app_logger(nlog)#$app_logger
14
+ ilog 'Application logger initialized in file %s'%logfile
15
+ end
16
+
17
+ ##
18
+ # принудительно меняем логер
19
+ #
20
+ def self.set_app_logger(logger)
21
+ $app_logger=logger
22
+ end
23
+
24
+ ##
25
+ # логгер по умолчанию
26
+ #
27
+ def self.null_logger
28
+ $null_logger||=Logger.new(STDERR)
29
+ end
30
+
31
+ ##
32
+ # получить глобальный объект логера
33
+ def app_logger
34
+ ZLogs::app_logger
35
+ end
36
+
37
+ ##
38
+ # получить глобальный объект логера
39
+ def self.app_logger
40
+ res_logger= ($app_logger||ZLogs::null_logger)
41
+ end
42
+ end
43
+ ##
44
+ # Определяем логирование для всего и вся
45
+ # Расширяем Kernel методами работы с логами
46
+ module Kernel
47
+ ##
48
+ # информационное сообщение в log
49
+ def ilog(*args)
50
+ ZLogs::app_logger.info args.join ' '
51
+ end
52
+
53
+ ##
54
+ # debug сообщение в log
55
+ def dlog(*args)
56
+ ZLogs::app_logger.debug args.join ' '
57
+ end
58
+
59
+ ##
60
+ # error сообщение в log
61
+ def elog(*args)
62
+ ZLogs::app_logger.error args.join ' '
63
+ end
64
+
65
+ ##
66
+ # rescue exception логирование
67
+ # дампим инфу об исключении подробно
68
+ # exc - объект исключения,
69
+ # msg - дополнительное сообщение
70
+ #
71
+ def rlog(exc, *msg)
72
+ # формируем сообщение:
73
+ # EXCEPTION exc.class
74
+ # MESSAGE: exc.message
75
+ # TRACE:
76
+ # exc.backtrace.join("\n\t")
77
+ #
78
+ strace = exc.backtrace||[]
79
+ exc||=Exception.new('<NULL EXCEPTION PASSED>')
80
+ dbg_msg="<<EXC# %s: %s>>
81
+ MESSAGE: %s
82
+ TRACE:
83
+ %s"
84
+ dlog (dbg_msg%[exc.class, exc.message, msg.join(' '), strace.join("\n\t\t")]).gsub(/^\s*[A-Z]+:\s*$/,'')
85
+ err_msg="Exception from [%s]: %s (%s)"
86
+ elog err_msg%[strace.first, exc.message, exc.class]
87
+ end
88
+
89
+ end
@@ -0,0 +1,3 @@
1
+ module ZLogs
2
+ VERSION = "0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'zlogs/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "zlogs"
8
+ spec.version = ZLogs::VERSION
9
+ spec.authors = ["ev42"]
10
+ spec.email = ["splin.ev42@gmail.com"]
11
+ spec.description = %q{Simple gem for global logging for app}
12
+ spec.summary = %q{Simple and ugly global (4 app) logs}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'syslog_protocol'
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zlogs
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - ev42
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: syslog_protocol
16
+ requirement: &10685020 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *10685020
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &10684520 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.3'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *10684520
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &10684100 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *10684100
47
+ description: Simple gem for global logging for app
48
+ email:
49
+ - splin.ev42@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - lib/zlogs.rb
60
+ - lib/zlogs/version.rb
61
+ - zlogs.gemspec
62
+ homepage: ''
63
+ licenses:
64
+ - MIT
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.11
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Simple and ugly global (4 app) logs
87
+ test_files: []