forked from layervault/psd.rb
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
0068f06
commit 462cc8b
Showing
4 changed files
with
64 additions
and
17 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
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
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
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 'logger' | ||
|
||
class PSD | ||
module Logger | ||
def self.included(base) | ||
base.extend(ClassMethods) | ||
end | ||
|
||
module ClassMethods | ||
@@debug = false | ||
|
||
def logger | ||
return @logger if @logger | ||
|
||
if @@debug || ENV['PSD_DEBUG'] | ||
@logger = ::Logger.new(debug_output) | ||
@logger.formatter = proc do |severity, datetime, progname, msg| | ||
"#{severity}: #{msg}\n" | ||
end | ||
else | ||
@logger = DisabledLogger.new | ||
end | ||
|
||
return @logger | ||
end | ||
|
||
def debug_output | ||
if ENV['PSD_DEBUG'] | ||
ENV['PSD_DEBUG'] == 'STDOUT' ? STDOUT : ENV['PSD_DEBUG'] | ||
end | ||
|
||
STDOUT | ||
end | ||
end | ||
end | ||
|
||
class DisabledLogger | ||
def method_missing(method, *args, &block) | ||
# silence | ||
end | ||
end | ||
end |