Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3e9ebec
Showing
19 changed files
with
1,281 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
^doc/ | ||
^coverage/ | ||
^pkg/ | ||
\.DS_Store | ||
ChangeLog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env ruby | ||
# vim: set nosta noet ts=4 sw=4: | ||
|
||
BEGIN { | ||
require 'pathname' | ||
$LOAD_PATH.unshift( Pathname.new( __FILE__ ).dirname + 'lib' ) | ||
} | ||
|
||
begin | ||
require 'loggability' | ||
rescue Exception => err | ||
$stderr.puts "Loggability failed to load: %p: %s" % [ err.class, err.message ] | ||
$stderr.puts( err.backtrace ) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# .gems generated gem export file. Note that any env variable settings will be missing. Append these after using a ';' field separator | ||
hoe-deveiate -v0.1.1 | ||
pluginfactory -v1.0.8 | ||
configurability -v1.1.0 | ||
rdoc -v3.12 | ||
simplecov -v0.6.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This is an RVM Project .rvmrc file, used to automatically load the ruby | ||
# development environment upon cd'ing into the directory | ||
|
||
environment_id="ruby-1.9.3@loggability" | ||
rvmdir=${rvm_path:-$HOME/.rvm} | ||
gemset_file=".rvm.gems" | ||
|
||
if [[ -d "${rvmdir}/environments" && -s "${rvmdir}/environments/$environment_id" ]]; then | ||
echo "Using ${environment_id}" | ||
. "${rvmdir}/environments/$environment_id" | ||
|
||
if [[ -s "${rvmdir}/hooks/after_use" ]]; then | ||
. "${rvmdir}/hooks/after_use" | ||
fi | ||
else | ||
# If the environment file has not yet been created, use the RVM CLI to select. | ||
if ! rvm --create use "$environment_id"; then | ||
echo "Failed to create RVM environment '${environment_id}'." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
if [[ -s "$gemset_file" ]]; then | ||
rvm gemset import "$gemset_file" | ||
fi | ||
|
||
echo "It doesn't bite the Chowderhouse." | ||
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
=== 1.0.0 / 2012-05-04 | ||
|
||
* 1 major enhancement | ||
|
||
* Birthday! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
ChangeLog | ||
History.rdoc | ||
Manifest.txt | ||
README.rdoc | ||
Rakefile | ||
bin/loggability | ||
lib/loggability.rb | ||
lib/loggability/constants.rb | ||
lib/loggability/exceptions.rb | ||
lib/loggability/formatter.rb | ||
lib/loggability/formatter/default.rb | ||
lib/loggability/formatter/html.rb | ||
lib/loggability/logger.rb | ||
spec/lib/helpers.rb | ||
spec/loggability/logger_spec.rb | ||
spec/loggability_spec.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
= loggability | ||
|
||
home :: http://deveiate.org/projects/loggability | ||
code :: http://bitbucket.org/ged/loggability | ||
docs :: http://deveiate.org/code/loggability | ||
github :: http://github.com/ged/loggability | ||
|
||
|
||
== Description | ||
|
||
Loggability is a wrapper around the 'logger' standard library that makes | ||
it easier to use for large systems. | ||
|
||
|
||
== Prerequisites | ||
|
||
* Ruby 1.9.3 or better, Rubinius 2.0 or better | ||
|
||
It will probably work under any other interpreter in which Logger works, but | ||
it's only tested in the above. | ||
|
||
|
||
== Installation | ||
|
||
$ gem install loggability | ||
|
||
|
||
== Usage | ||
|
||
Loggability is split up into two parts: {log hosts}[rdoc-ref:Loggability::LogHost] | ||
and {log clients}[rdoc-ref:Loggability::LogClient]. A <b>log | ||
host</b> is an object that contains a Logger instance that will be used to | ||
log stuff. A <b>log client</b> is an object that will write logging messages to a | ||
particular <b>log host</b>. | ||
|
||
Both parts require that you extend the object with Loggability. | ||
|
||
=== Setting Up A 'Log Host' | ||
|
||
To install a Logger into an object, you use the +log_as+ declaration with a | ||
Symbol that will be used as the key for the object's Logger: | ||
|
||
module MyProject | ||
extend Loggability | ||
log_as :my_project | ||
end | ||
|
||
After declaring itself as a log host, it will have an associated Loggability::Logger | ||
object that's a wrapper around a Logger instance: | ||
|
||
MyProject.logger | ||
# => #<Loggability::Logger:0x4e0c :my_project ...> | ||
|
||
You can call all the regular Logger methods: | ||
|
||
MyProject.logger.level = Logger::WARN | ||
|
||
MyProject.logger.debug("Created logger") | ||
MyProject.logger.info("Program started") | ||
MyProject.logger.warn("Nothing to do!") | ||
|
||
begin | ||
File.each_line(path) do |line| | ||
unless line =~ /^(\w+) = (.*)$/ | ||
MyProject.logger.error("Line in wrong format: #{line}") | ||
end | ||
end | ||
rescue => err | ||
MyProject.logger.fatal("Caught exception; exiting") | ||
MyProject.logger.fatal(err) | ||
end | ||
|
||
or use a few new convenience methods for changing the logging level: | ||
|
||
MyProject.logger.level = :debug | ||
|
||
...installing a different formatter: | ||
|
||
MyProject.logger.format_as( :html ) | ||
|
||
...changing the output destination: | ||
|
||
log_messages = [] | ||
MyProject.logger.output_to( log_messages ) | ||
|
||
...{and more}[rdoc-ref:Loggability::Logger]. | ||
|
||
|
||
=== Setting Up A 'Log Client' | ||
|
||
To add an object that will log to your log host, after you <tt>extend Loggability</tt>, | ||
use the +log_to+ declaration to hook up the object (and instances of the object if | ||
you use +log_to+ in a Class) to the log host you specify: | ||
|
||
class MyProject::Server | ||
extend Loggability | ||
log_to :my_project | ||
|
||
def initialize( config={} ) | ||
self.log.debug "Creating a server with config: %p" % [ config ] | ||
#... | ||
end | ||
end | ||
|
||
You can fetch any object's Logger through the Loggability object: | ||
|
||
Loggability[ MyProject ] | ||
# => #<Loggability::Logger:0x007f88ca3bf510 ...> | ||
|
||
Loggability[ MyProject::Server ] | ||
# => #<Loggability::Logger:0x007f88ca3bf510 ...> | ||
|
||
Calling the object's <tt>#log</tt> method will return a Proxy for its host's Logger object that will include the object's name in the log messages 'progname'. | ||
|
||
You can also use the <b>log host</b> itself as the argument to +log_to+: | ||
|
||
class MyProject::Client | ||
extend Loggability | ||
log_to MyProject | ||
end | ||
|
||
|
||
=== Aggregate Logging | ||
|
||
If you have several <b>log hosts</b>, and you want to affect them all simultaneously, | ||
you can do that using the aggregate functions of Loggability. They're the same as the | ||
methods on Loggability::Logger: | ||
|
||
# Set all logs to log at INFO level | ||
Loggability.level = :info | ||
|
||
# Write HTML logs | ||
Loggability.format_with( :html ) | ||
|
||
# Log everything to the same logfile | ||
Loggability.output_to( "/tmp/my_project_log.html" ) | ||
|
||
|
||
== Contributing | ||
|
||
You can check out the current development source with | ||
Mercurial[http://bitbucket.org/ged/loggability], or if you prefer Git, via | ||
{its Github mirror}[https://github.com/ged/loggability]. | ||
|
||
After checking out the source, run: | ||
|
||
$ rake newb | ||
|
||
This task will install any missing dependencies, run the tests/specs, | ||
and generate the API documentation. | ||
|
||
|
||
== License | ||
|
||
Copyright (c) 2012, Michael Granger | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the author/s, nor the names of the project's | ||
contributors may be used to endorse or promote products derived from this | ||
software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env rake | ||
|
||
require 'rake/clean' | ||
|
||
begin | ||
require 'hoe' | ||
rescue LoadError | ||
abort "This Rakefile requires 'hoe' (gem install hoe)" | ||
end | ||
|
||
Hoe.plugin :mercurial | ||
Hoe.plugin :signing | ||
Hoe.plugin :deveiate | ||
|
||
Hoe.plugins.delete :rubyforge | ||
|
||
hoespec = Hoe.spec 'loggability' do | ||
self.readme_file = 'README.rdoc' | ||
self.history_file = 'History.rdoc' | ||
self.extra_rdoc_files = FileList[ '*.rdoc' ] | ||
|
||
self.developer 'Michael Granger', 'ged@FaerieMUD.org' | ||
|
||
self.dependency 'pluginfactory', '~> 1.0' | ||
|
||
self.dependency 'hoe-deveiate', '~> 0.1', :developer | ||
self.dependency 'simplecov', '~> 0.6', :developer | ||
|
||
self.spec_extras[:licenses] = ["Ruby"] | ||
self.spec_extras[:rdoc_options] = ['-f', 'fivefish', '-t', 'Loggability Toolkit'] | ||
self.require_ruby_version( '>=1.9.3' ) | ||
self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= ) | ||
self.check_history_on_release = true if self.respond_to?( :check_history_on_release= ) | ||
|
||
self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}" | ||
end | ||
|
||
ENV['VERSION'] ||= hoespec.spec.version.to_s | ||
|
||
# Ensure the specs pass before checking in | ||
task 'hg:precheckin' => [ :check_history, :check_manifest, :spec ] | ||
|
||
|
||
desc "Build a coverage report" | ||
task :coverage do | ||
ENV["COVERAGE"] = 'yes' | ||
Rake::Task[:spec].invoke | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env ruby | ||
|
||
abort "you need to write me" |
Oops, something went wrong.