remote_logger 0.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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +61 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/features/remote_logger.feature +9 -0
- data/features/step_definitions/remote_logger_steps.rb +0 -0
- data/features/support/env.rb +4 -0
- data/lib/remote_logger/remote_logger.rb +104 -0
- data/lib/remote_logger.rb +24 -0
- data/spec/remote_logger/remote_logger_spec.rb +132 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +48 -0
- metadata +89 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 arvicco
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
remote_logger
|
2
|
+
by: arvicco
|
3
|
+
url: http://github.com/arvicco/remote_logger
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Log server/client with sensible defaults that can be used for remote/centralized logging.
|
8
|
+
|
9
|
+
== FEATURES:
|
10
|
+
|
11
|
+
Log4r is a customizable logger with advanced functionality. Unfortunately, it only supports (rarely used) ROMP protocol
|
12
|
+
for remote logging support. This project aims to improve remote logging by creatting a wrapper around Log4r that:
|
13
|
+
* Exposes Log4r functionality remotely through multiple protocols
|
14
|
+
* Writes to (log server) stdout AND log file 'remote.log' by default
|
15
|
+
* Allows client to use Drb uri or Ring server to find the logger service
|
16
|
+
|
17
|
+
== PROBLEMS/TODO:
|
18
|
+
|
19
|
+
* TODO: add AMQP rpc support
|
20
|
+
|
21
|
+
Work in progress, please do not use it just yet...
|
22
|
+
|
23
|
+
== SYNOPSIS:
|
24
|
+
|
25
|
+
server:
|
26
|
+
---
|
27
|
+
include RemoteLogger
|
28
|
+
start_drb_logger [options] # or,
|
29
|
+
start_ringy_logger [options]
|
30
|
+
---
|
31
|
+
|
32
|
+
client:
|
33
|
+
---
|
34
|
+
include RemoteLogger
|
35
|
+
log = find_drb_logger [options] # or,
|
36
|
+
log = find_ringy_logger [options]
|
37
|
+
log.info 'This is my log message'
|
38
|
+
---
|
39
|
+
|
40
|
+
== REQUIREMENTS:
|
41
|
+
|
42
|
+
* FIXME (list of requirements)
|
43
|
+
|
44
|
+
== INSTALL:
|
45
|
+
|
46
|
+
sudo gem install remote_logger
|
47
|
+
|
48
|
+
|
49
|
+
== Note on Patches/Pull Requests
|
50
|
+
|
51
|
+
* Fork the project.
|
52
|
+
* Make your feature addition or bug fix.
|
53
|
+
* Add tests for it. This is important so I don't break it in a
|
54
|
+
future version unintentionally.
|
55
|
+
* Commit, do not mess with rakefile, version, or history.
|
56
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
57
|
+
* Send me a pull request. Bonus points for topic branches.
|
58
|
+
|
59
|
+
== Copyright
|
60
|
+
|
61
|
+
Copyright (c) 2010 arvicco. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "remote_logger"
|
8
|
+
gem.summary = %Q{Remote logger based on Log4r}
|
9
|
+
gem.description = %Q{Remote logger based on Log4r}
|
10
|
+
gem.email = "arvitallian@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/arvicco/remote_logger"
|
12
|
+
gem.authors = ["arvicco"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
gem.add_development_dependency "cucumber", ">= 0"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
end
|
27
|
+
|
28
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
spec.rcov = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :spec => :check_dependencies
|
35
|
+
|
36
|
+
begin
|
37
|
+
require 'cucumber/rake/task'
|
38
|
+
Cucumber::Rake::Task.new(:features)
|
39
|
+
|
40
|
+
task :features => :check_dependencies
|
41
|
+
rescue LoadError
|
42
|
+
task :features do
|
43
|
+
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
task :default => :spec
|
48
|
+
|
49
|
+
require 'rake/rdoctask'
|
50
|
+
Rake::RDocTask.new do |rdoc|
|
51
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
52
|
+
|
53
|
+
rdoc.rdoc_dir = 'rdoc'
|
54
|
+
rdoc.title = "remote_logger #{version}"
|
55
|
+
rdoc.rdoc_files.include('README*')
|
56
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
File without changes
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
# TODO: Set up ACL, SSL and other security stuff
|
3
|
+
module RemoteLogger
|
4
|
+
include Log4r
|
5
|
+
|
6
|
+
DRB_URI = 'druby://127.0.0.1:61626'
|
7
|
+
LOGGER_NAME = 'RemoteLogger' # Default service/logger name - used by Ring or retrieved via Log4R::Logger[LOGGER_NAME]
|
8
|
+
FILE_NAME = 'remote.log' # File name of log file
|
9
|
+
FILE_ENCODING = 'CP1251:UTF-8' # Encoding pair of log file ('File external:Ruby internal')
|
10
|
+
STDOUT_ENCODING = 'CP866:UTF-8' # Encoding pair of stdout ('Stdout external:Ruby internal')
|
11
|
+
PATTERN = '%1.1l %d - %m' # Log entry pattern
|
12
|
+
DATE_PATTERN = '%Y-%m-%d %H:%M:%S.%3N'
|
13
|
+
|
14
|
+
# Creates a new Log4r logger. The following options are available:
|
15
|
+
#
|
16
|
+
# <tt>:name</tt>:: Service/logger name - default 'RemoteLogger'
|
17
|
+
# <tt>:outputters</tt>:: Replace outputters (should be Log4r::Outputter subclasses) - default [log file, stdout]
|
18
|
+
# <tt>:file_name</tt>:: Log file name - default 'remote.log'
|
19
|
+
# <tt>:file_encoding</tt>:: Log file encoding - default FILE_ENCODING (Windows Cyrillic)
|
20
|
+
# <tt>:stdout_encoding</tt>:: Stdout encoding - default STDOUT_ENCODING (DOS/IBM Cyrillic)
|
21
|
+
# <tt>:replace</tt>:: Replacement for undefined conversion chars - default '?'
|
22
|
+
# <tt>:pattern</tt>:: Log message pattern - default PATTERN
|
23
|
+
# <tt>:date_pattern</tt>:: Timestamp pattern - default DATE_PATTERN
|
24
|
+
# <tt>:trunc</tt>:: Truncate (rewrite) log file upon creation - default false (append to file)
|
25
|
+
# <tt>:verbose</tt>:: Log all internal messages of RemoteLogger - default false (do not log logger-specific messages)
|
26
|
+
#
|
27
|
+
def self.create_logger options = {}
|
28
|
+
# define outputters: http://log4r.sourceforge.net/rdoc/files/log4r/outputter/outputter_rb.html
|
29
|
+
if options[:outputters]
|
30
|
+
outputters = options[:outputters]
|
31
|
+
else
|
32
|
+
# specify log message format: http://log4r.sourceforge.net/rdoc/files/log4r/formatter/patternformatter_rb.html
|
33
|
+
format = PatternFormatter.new :pattern => options[:pattern]||PATTERN,
|
34
|
+
:date_pattern => options[:date_pattern]||DATE_PATTERN
|
35
|
+
|
36
|
+
# Set up IO streams with correct transcoding and conversion options: log file and (Windows) console
|
37
|
+
conversion = {:undef=>:replace, :replace=>options[:replace]||'?'}
|
38
|
+
file = File.new(options[:file_name]||FILE_NAME, (options[:trunc] ? 'w:' : 'a:') +
|
39
|
+
(options[:file_encoding]||FILE_ENCODING), conversion )
|
40
|
+
$stdout.set_encoding(options[:stdout_encoding]||STDOUT_ENCODING, conversion)
|
41
|
+
|
42
|
+
outputters = [StdoutOutputter.new('console', :formatter => format),
|
43
|
+
IOOutputter.new('file', file, :formatter => format) ]
|
44
|
+
# file_o = FileOutputter.new 'file', :filename => 'remote.log', :trunc => false, :formatter => format # wrong encoding
|
45
|
+
# err_o = StderrOutputter.new 'error', :formatter => format # just in case
|
46
|
+
end
|
47
|
+
|
48
|
+
# create new logger named LOG_NAME
|
49
|
+
Logger.new(options[:name]||LOGGER_NAME).tap do |logger|
|
50
|
+
logger.outputters = outputters
|
51
|
+
logger.info "#{name}: Logger created" if options[:verbose]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.start_ringy_logger(name = LOGGER_NAME, options = {})
|
56
|
+
# Adding some security (disable remote eval)
|
57
|
+
$SAFE = 1
|
58
|
+
|
59
|
+
# Creating logger instance
|
60
|
+
logger = create_logger options
|
61
|
+
|
62
|
+
DRb.start_service
|
63
|
+
|
64
|
+
# Raising new RingyDingy service
|
65
|
+
logger.info "#{name}: Initializing service..." if options[:verbose]
|
66
|
+
RingyDingy.new(logger, name.to_sym).run
|
67
|
+
logger.info "#{name}: Service started" if options[:verbose]
|
68
|
+
|
69
|
+
DRb.thread.join
|
70
|
+
logger.info "#{name}: Service finished" if options[:verbose]
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.find_ringy_logger(name = LOGGER_NAME, options = {})
|
74
|
+
DRb.start_service
|
75
|
+
# Connecting to Logger
|
76
|
+
ring_server = Rinda::RingFinger.primary
|
77
|
+
service = ring_server.read [:name, name.to_sym, nil, nil]
|
78
|
+
service[2]
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.start_drb_logger(name = LOGGER_NAME, options = {})
|
82
|
+
# Adding some security (disable remote eval)
|
83
|
+
$SAFE = 1
|
84
|
+
|
85
|
+
# Creating logger instance
|
86
|
+
logger = create_logger options
|
87
|
+
|
88
|
+
# Raising new RingyDingy service
|
89
|
+
logger.info "#{name}: Initializing service..." if options[:verbose]
|
90
|
+
DRb.start_service(options[:uri]||DRB_URI, logger)
|
91
|
+
logger.info "#{name}: Service started" if options[:verbose]
|
92
|
+
|
93
|
+
DRb.thread.join
|
94
|
+
logger.info "#{name}: Service finished" if options[:verbose]
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.find_drb_logger(name = LOGGER_NAME, options = {})
|
98
|
+
DRb.start_service
|
99
|
+
# Connecting to Logger
|
100
|
+
log = DRbObject.new_with_uri(options[:uri]||DRB_URI)
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
require 'rinda/ring'
|
3
|
+
require 'ringy_dingy'
|
4
|
+
#require 'ringy_dingy/ring_server'
|
5
|
+
|
6
|
+
module RemoteLogger
|
7
|
+
|
8
|
+
# Utility method used to require all files ending in .rb that lie in the
|
9
|
+
# directory below this file that has the same name as the filename passed
|
10
|
+
# in. Optionally, a specific _directory_ name can be passed in such that
|
11
|
+
# the _filename_ does not have to be equivalent to the directory.
|
12
|
+
#
|
13
|
+
def self.require_all_libs_relative_to( fname, dir = nil )
|
14
|
+
dir ||= ::File.basename(fname, '.*')
|
15
|
+
search_me = ::File.expand_path(
|
16
|
+
::File.join(::File.dirname(fname), dir, '**', '*.rb'))
|
17
|
+
|
18
|
+
Dir.glob(search_me).sort.each {|rb| require rb}
|
19
|
+
end
|
20
|
+
|
21
|
+
end # module RemoteLogger
|
22
|
+
|
23
|
+
RemoteLogger.require_all_libs_relative_to(__FILE__)
|
24
|
+
|
@@ -0,0 +1,132 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
require_relative '../spec_helper'
|
3
|
+
|
4
|
+
module RemoteLoggerTest
|
5
|
+
describe RemoteLogger do
|
6
|
+
before(:each) do
|
7
|
+
File.stub!(:new) {|name, mode, opts| @logfile_mock = StringIO.new('', mode) }
|
8
|
+
end
|
9
|
+
|
10
|
+
spec {use { include RemoteLogger}}
|
11
|
+
|
12
|
+
shared_examples_for 'Log4r proxy' do
|
13
|
+
context ' by default' do
|
14
|
+
it 'creates Log4r logger with default name "RemoteLogger"' do
|
15
|
+
logger = RemoteLogger.create_logger
|
16
|
+
logger.should be_an_instance_of Log4r::Logger
|
17
|
+
logger.should == Log4r::Logger['RemoteLogger']
|
18
|
+
logger.should == RemoteLogger::Logger['RemoteLogger']
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'outputs log messages to IOstream(file) and stdout simultaneously' do
|
22
|
+
outputters = RemoteLogger.create_logger.outputters
|
23
|
+
outputters.should have(2).outputters
|
24
|
+
outputters.first.should be_an_instance_of Log4r::StdoutOutputter
|
25
|
+
outputters.last.should be_an_instance_of Log4r::IOOutputter
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'appends to logfile "remote.log" with Windows-1251(Cyrillic) encoding' do
|
29
|
+
File.should_receive(:new) do |filename, mode, options|
|
30
|
+
filename.should == "remote.log"
|
31
|
+
mode.should =~ /^a:/
|
32
|
+
mode.should =~ /(CP|cp)1251:/
|
33
|
+
end
|
34
|
+
logger = RemoteLogger.create_logger
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'writes to stdout with IBM-866(DOS-Cyrillic) encoding' do
|
38
|
+
$stdout.should_receive(:set_encoding).with(/(CP|cp)866:/, hash_including(:undef))
|
39
|
+
logger = RemoteLogger.create_logger
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'logs string messages using default pattern' do
|
43
|
+
logger = RemoteLogger.create_logger
|
44
|
+
logger_should_log 'I %Y-%m-%d %H:%M:\d{2}.\d{3} - My message\n'
|
45
|
+
logger.info 'My message'
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'logs logger creation announcement'
|
49
|
+
|
50
|
+
it 'replaces illegal chars in output codepages with ?' do
|
51
|
+
pending 'Impossible to test without real files'
|
52
|
+
logger_should_log 'I %Y-%m-%d %H:%M:\d{2}.\d{3} - My ? message\n'
|
53
|
+
logger = RemoteLogger.create_logger
|
54
|
+
logger.info 'My 昔 message'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'with options' do
|
59
|
+
it 'accepts logger name with :name option' do
|
60
|
+
logger = RemoteLogger.create_logger :name=>'MyLogger'
|
61
|
+
logger.should == Log4r::Logger['MyLogger']
|
62
|
+
logger.should == RemoteLogger::Logger['MyLogger']
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'accepts logfile name with :file_name option' do
|
66
|
+
File.should_receive(:new).with('my_name.log', anything, anything)
|
67
|
+
logger = RemoteLogger.create_logger :file_name=>'my_name.log'
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'accepts custom log pattern with :pattern option' do
|
71
|
+
logger = RemoteLogger.create_logger :pattern=>'%d %l %7.7m'
|
72
|
+
logger_should_log '%Y-%m-%d %H:%M:\d{2}.\d{3} INFO My mess\n'
|
73
|
+
logger.info 'My message'
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'accepts custom date pattern with :date_pattern option' do
|
77
|
+
logger = RemoteLogger.create_logger :date_pattern=>'%m/%d/%y'
|
78
|
+
logger_should_log 'I %m/%d/%y - My message\n'
|
79
|
+
logger.info 'My message'
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'accepts custom file encoding with :file_encoding option' do
|
83
|
+
File.should_receive(:new).with(anything, /^a:CP866/, anything)
|
84
|
+
logger = RemoteLogger.create_logger :file_encoding=>'CP866'
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'accepts custom stdout encoding with :stdout_encoding option' do
|
88
|
+
$stdout.should_receive(:set_encoding).with(/CP1251/, hash_including(:undef))
|
89
|
+
logger = RemoteLogger.create_logger :stdout_encoding=>'CP1251'
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'accepts custom outputters with :outputters option, replacing default outputters' do
|
93
|
+
out_string = StringIO.new
|
94
|
+
$stdout.should_not_receive(:set_encoding)
|
95
|
+
File.should_not_receive(:new)
|
96
|
+
logger = RemoteLogger.create_logger :outputters=>Log4r::IOOutputter.new('errors', out_string)
|
97
|
+
$stdout.should_not_receive(:print)
|
98
|
+
out_string.should_receive(:print).with " INFO RemoteLogger: My message\n"
|
99
|
+
logger.info 'My message'
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'rewrites logfile with :trunc option' do
|
103
|
+
File.should_receive(:new).with(anything, /^w:/, anything)
|
104
|
+
# File.new(options[:file_name]||FILE_NAME, (options[:trunc] ? 'w:' : 'a:') +
|
105
|
+
# (options[:file_encoding]||FILE_ENCODING), :undef => options[:undef]||:replace)
|
106
|
+
logger = RemoteLogger.create_logger :trunc=>true
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'specifies conversion replacement char with :replace option' do
|
110
|
+
pending 'Impossible to test without real files'
|
111
|
+
File.should_receive(:new).with(anything, anything, hash_including(:replace))
|
112
|
+
# File.new(options[:file_name]||FILE_NAME, (options[:trunc] ? 'w:' : 'a:') +
|
113
|
+
# (options[:file_encoding]||FILE_ENCODING), :undef => options[:undef]||:replace)
|
114
|
+
logger = RemoteLogger.create_logger #:replace=>'-'
|
115
|
+
logger_should_log '%Y-%m-%d %H:%M:\d{2}.\d{3} INFO My - message\n'
|
116
|
+
logger.info 'My 昔 message'
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'skips logger creation announcement with :silent option'
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'creating Drb logger' do
|
124
|
+
spec{ pending; use{ RemoteLogger.start_drb_logger(name = 'RemoteLogger', options = {})}}
|
125
|
+
it_should_behave_like 'Log4r proxy'
|
126
|
+
|
127
|
+
it 'instantiates drb logger service' do
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
lib_dir = File.join(File.dirname(__FILE__), "..", "lib" )
|
2
|
+
$LOAD_PATH.unshift lib_dir unless $LOAD_PATH.include?(lib_dir)
|
3
|
+
require 'remote_logger'
|
4
|
+
|
5
|
+
# Module that extends RSpec with my own extensions/macros
|
6
|
+
module SpecMacros
|
7
|
+
|
8
|
+
# Wrapper for *it* method that extracts description from example source code, such as:
|
9
|
+
# spec{ use{ result = function(arg1 = 4, arg2 = 'string') }}
|
10
|
+
def spec &block
|
11
|
+
it description_from(*block.source_location), &block
|
12
|
+
end
|
13
|
+
|
14
|
+
# reads description line from source file and drops external brackets (like *spec*{}, *use*{})
|
15
|
+
def description_from(file, line)
|
16
|
+
File.open(file) do |f|
|
17
|
+
f.lines.to_a[line-1].gsub( Regexp.new('(spec.*?{)|(use.*?{)|}'), '' ).lstrip.rstrip
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Spec::Runner.configure { |config| config.extend(SpecMacros) }
|
23
|
+
|
24
|
+
module RemoteLoggerTest
|
25
|
+
|
26
|
+
# Test related Constants:
|
27
|
+
TEST_NAME = 'MyLogger'
|
28
|
+
TEST_STRING = 'This is test string'
|
29
|
+
|
30
|
+
# Checks that given block does not raise any errors
|
31
|
+
def use
|
32
|
+
lambda {yield}.should_not raise_error
|
33
|
+
end
|
34
|
+
|
35
|
+
# Returns empty block (for use in spec descriptions)
|
36
|
+
def any_block
|
37
|
+
lambda {|*args| args}
|
38
|
+
end
|
39
|
+
|
40
|
+
# Sets expectations of receiving timestamped message on both logfile mock and stdout
|
41
|
+
def logger_should_log message
|
42
|
+
formatted_message = Time.now.strftime message
|
43
|
+
# logfile = mock('logfile').as_null_object
|
44
|
+
# File.stub(:new).and_return(logfile)
|
45
|
+
@logfile_mock.should_receive(:print).with(Regexp.new(formatted_message))
|
46
|
+
$stdout.should_receive(:print).with(Regexp.new(formatted_message))
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: remote_logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- arvicco
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-22 00:00:00 +03:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.9
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: cucumber
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: Remote logger based on Log4r
|
36
|
+
email: arvitallian@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- features/remote_logger.feature
|
52
|
+
- features/step_definitions/remote_logger_steps.rb
|
53
|
+
- features/support/env.rb
|
54
|
+
- lib/remote_logger.rb
|
55
|
+
- lib/remote_logger/remote_logger.rb
|
56
|
+
- spec/remote_logger/remote_logger_spec.rb
|
57
|
+
- spec/spec.opts
|
58
|
+
- spec/spec_helper.rb
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://github.com/arvicco/remote_logger
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options:
|
65
|
+
- --charset=UTF-8
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.3.5
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Remote logger based on Log4r
|
87
|
+
test_files:
|
88
|
+
- spec/remote_logger/remote_logger_spec.rb
|
89
|
+
- spec/spec_helper.rb
|