Class: Onebot::Logging::EventLogger
- Inherits:
-
Object
- Object
- Onebot::Logging::EventLogger
- Defined in:
- lib/Core/Logging/EventLogger.rb
Instance Method Summary collapse
-
#dataParse(msg) ⇒ Object
消息解析部分.
-
#initialize(logger = nil) ⇒ EventLogger
constructor
A new instance of EventLogger.
- #log(str, severity = ::Logger::INFO, app = 'Onebot') ⇒ Object
Constructor Details
#initialize(logger = nil) ⇒ EventLogger
Returns a new instance of EventLogger.
4 5 6 |
# File 'lib/Core/Logging/EventLogger.rb', line 4 def initialize(logger = nil) @logger = logger end |
Instance Method Details
#dataParse(msg) ⇒ Object
消息解析部分
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/Core/Logging/EventLogger.rb', line 17 def dataParse(msg) return if @logger.nil? # 连接成功 @selfID = msg.self_id if msg. == 'lifecycle' && msg.sub_type == 'connect' @logger.log(msg.to_json, ::Logger::DEBUG) if msg. != 'heartbeat' # 过滤心跳 case msg.post_type # # 请求事件 # when 'request' onReq(msg) # # 提醒事件 # when 'notice' onNotice(msg) # # 消息事件 # when 'message' onMsg(msg) end end |
#log(str, severity = ::Logger::INFO, app = 'Onebot') ⇒ Object
8 9 10 11 12 |
# File 'lib/Core/Logging/EventLogger.rb', line 8 def log(str, severity = ::Logger::INFO, app = 'Onebot') return if @logger.nil? @logger.log(str, severity, app) end |