lib/tlogger/tlogger.rb in tlogger-0.26.2 vs lib/tlogger/tlogger.rb in tlogger-0.26.3
- old
+ new
@@ -316,9 +316,37 @@
#
def show_source
@include_caller = true
end
+ # detect if the prompt should be to env or file
+ def self.init(out = STDOUT)
+ if is_dev?
+ Tlogger.new(out)
+ else
+ path = ENV["TLOGGER_FILE_PATH"]
+ if path.nil? or path.empty?
+ Tlogger.new(nil)
+ else
+ path = [path] if not path.is_a?(Array)
+ Tlogger.new(*path)
+ end
+ end
+ end
+
+ def self.set_dev_mode
+ ENV["TLOGGER_MODE"] = "dev"
+ end
+
+ def self.set_production_mode
+ ENV.delete("TLOGGER_MODE")
+ end
+
+ def self.is_dev?
+ ENV.keys.include?("TLOGGER_MODE") and ENV["TLOGGER_MODE"].downcase == "dev"
+ end
+
+
private
def format_message(key)
# returning args array
if @include_caller
"[#{key}] #{find_caller} "