-
Notifications
You must be signed in to change notification settings - Fork 4
/
loger.py
26 lines (22 loc) · 704 Bytes
/
loger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'''
@Author: your name
@Date: 2020-03-17 10:26:01
@LastEditTime: 2020-03-17 10:39:40
@LastEditors: Please set LastEditors
@Description: In User Settings Edita
@FilePath: \data process\loger.py
'''
import json
class logger():
def __init__(self,log_path):
''' log path'''
self.path=log_path
def _write_json(self,filename,data,mode='w+'):
file_path='{}/{}'.format(self.path,filename)
with open(file_path,mode) as f:
json.dump(data,f)
print('Logging json completed')
def Log_append(self,filename,data):
self._write_json(filename,data,'a')
def Log_write(self,filename,data):
self._write_json(filename,data)