123456789101112131415161718192021 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- demeter service
- name:record_log.py 记录网关日志
- author:rabin
- key:log/hw/gateway/gateway
- """
- from demeter.core import *
- class Record_log(object):
- def handle(self, record, config, value):
- model = Demeter.model('device_gateway')
- model.hardware_id = config['parent']
- data = model.select(type='fetchone')
- if data:
- logModel = Demeter.model('log')
- logModel.farm_id = data['farm_id']
- logModel.gateway_id = data['id']
- logModel.content = value
- logModel.insert()
|