【发布时间】:2018-10-07 06:34:41
【问题描述】:
我的 Python 脚本使用
log.startLogging(sys.stdout)
和log.startLogging(DailyLogFile.fromFullPath('sms.log'))。它做得很好。
但它有点笨重和沉闷。所以我不想将它解析为带有特定标签且没有不必要信息的 XML,所以它对人眼来说更美观。
已发送内容和发送给谁的信息:电话号码 (29999999)、文本 (text1)、用户 ID (666) 和事件 ID (1):
2018-04-26 11:42:25+0300 [-] ('29999999', 'text1', '666', '1')
2018-04-26 11:42:25+0300 [SMSManagementProtocol,client] TX WAMP: [7,"psevent:send_sms",{"sms_txt":"text1","id_nr":"666","key":"1","phone_nr":"29999999"},null]
2018-04-26 11:42:25+0300 [-] ('29999999', 'text2', '666', '2')
2018-04-26 11:42:25+0300 [SMSManagementProtocol,client] TX WAMP: [7,"psevent:send_sms",{"sms_txt":"text2","id_nr":"666","key":"2","phone_nr":"29999999"},null]
2018-04-26 11:42:25+0300 [-] ('29999999', 'text3', '666', '3')
2018-04-26 11:42:25+0300 [SMSManagementProtocol,client] TX WAMP: [7,"psevent:send_sms",{"sms_txt":"text3","id_nr":"666","key":"3","phone_nr":"29999999"},null]
EVENT(送达或发生错误时响应状态):
2018-04-26 11:43:23+0300 [-] EVENT: http://test.com/publicsubscribeon_sms_delivered_OK KEY: 1
2018-04-26 11:43:23+0300 [SMSManagementProtocol,client] RX WAMP: [8, "http://test.com/publicsubscribeon_sms_delivered_OK", "3"]
2018-04-26 11:43:23+0300 [-] EVENT: http://test.com/publicsubscribeon_sms_delivered_OK KEY: 3
2018-04-26 11:43:23+0300 [SMSManagementProtocol,client] RX WAMP: [8, "http://test.com/publicsubscribeon_sms_delivered_OK", "2"]
2018-04-26 11:43:23+0300 [-] EVENT: http://test.com/publicsubscribeon_sms_delivered_OK KEY: 2
有没有办法删除不必要的日志信息?我需要的只是数据。
有什么建议吗?
【问题讨论】:
-
什么是“不必要的”?什么是“数据”?
-
不必要的,例如:'[SMSManagementProtocol,client] TX WAMP: [7,"psevent:send_sms",' 和:'[8, "test.com/publicsubscribeon_sms_delivered_OK",' 我只需要 "KEY : 1"/ "key 2" 等等。因为它是信息 - 正是事件成功了。这就是我需要的所有信息。(更多信息 = 更多存储空间,这不好)。