Module: Keystone::Base
- Defined in:
- lib/keystone/base.rb
Overview
ログレベルに関してのローカルルール(ログ確認に関して)debug 対応不要info 対応不要warn 複数個で営業時間内対応notice 1つで営業時間内対応error 1つで営業時間内対応alert 複数個で即時対応critical 1つで即時対応
Instance Method Summary collapse
- #alert(message) ⇒ Object
- #critical(message) ⇒ Object
- #debug(message) ⇒ Object
- #error(message) ⇒ Object
- #info(message) ⇒ Object
- #log(log_type, message, is_base_info = true) ⇒ Object
- #notice(message) ⇒ Object
- #warn(message) ⇒ Object
Instance Method Details
#alert(message) ⇒ Object
45 46 47 |
# File 'lib/keystone/base.rb', line 45 def alert() log(:ALERT,) end |
#critical(message) ⇒ Object
49 50 51 |
# File 'lib/keystone/base.rb', line 49 def critical() log(:CRIT,) end |
#debug(message) ⇒ Object
53 54 55 56 57 |
# File 'lib/keystone/base.rb', line 53 def debug() if $DEBUG log(:DEBUG,) end end |
#error(message) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/keystone/base.rb', line 22 def error() if .is_a? Exception log(:ERROR,"#{message.message}") .backtrace.each_with_index {|line, i| log(:ERROR,"#{line})",false) } else log(:ERROR,.to_s) end end |
#info(message) ⇒ Object
33 34 35 |
# File 'lib/keystone/base.rb', line 33 def info() log(:INFO,) end |
#log(log_type, message, is_base_info = true) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/keystone/base.rb', line 14 def log(log_type,, is_base_info = true) if is_base_info puts "[#{Time.now.strftime("%Y/%m/%d %H:%M:%S")}][#{$$}][#{log_type.to_s}] #{message}" else puts "[#{log_type.to_s}] #{message}" end end |
#notice(message) ⇒ Object
41 42 43 |
# File 'lib/keystone/base.rb', line 41 def notice() log(:NOTICE,) end |
#warn(message) ⇒ Object
37 38 39 |
# File 'lib/keystone/base.rb', line 37 def warn() log(:WARN,) end |