-
Notifications
You must be signed in to change notification settings - Fork 2
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
Rob Hurring
committed
Mar 10, 2011
1 parent
facd6fa
commit 6facb59
Showing
2 changed files
with
43 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pkg/* | ||
*.gem | ||
.bundle | ||
*.log |
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,42 @@ | ||
require File.expand_path('../../lib/class_logger', __FILE__) | ||
$log_path = File.dirname(__FILE__) | ||
|
||
# test module functionality | ||
module Hello | ||
include ClassLogger | ||
has_logger :in => "%{class_name}.log", :as => :my_logger | ||
|
||
def self.alternate | ||
loggers[:my_logger] | ||
end | ||
end | ||
Hello.my_logger.info "Hai" | ||
Hello.alternate.info "Hai der!" | ||
|
||
# test class functionality | ||
class Gateway | ||
include ClassLogger | ||
has_logger :path => $log_path, :level => Logger::ERROR | ||
has_logger :in => "%{caller_path}/transaction.log", :as => :transaction_logger, | ||
:formatter => proc{ |severity, time, program_name, message| "[%s-Transaction]: %s\n" % [severity, message] } | ||
|
||
def initialize | ||
logger.info "Wont show up" | ||
logger.error "Will show up" | ||
end | ||
|
||
def transact! | ||
transaction_logger.info "Transacted" | ||
end | ||
end | ||
|
||
g = Gateway.new | ||
g.transact! | ||
|
||
# test default functionality | ||
class Default | ||
include ClassLogger | ||
has_logger :path => "%{caller_path}" | ||
end | ||
|
||
Default.new.logger.info "Testing" |