-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.py
More file actions
24 lines (21 loc) · 709 Bytes
/
Log.py
File metadata and controls
24 lines (21 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
#coding=utf-8
import sys
import os,json
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)) + "/..")
import time
import time
from aliyun.log.logitem import LogItem
from aliyun.log.putlogsrequest import PutLogsRequest
class Log:
@staticmethod
def write(client, project, logstore, topic, source, contents):
# contents = [('Data', 'Data1')]
logitemList = [] # LogItem list
logItem = LogItem()
logItem.set_time(int(time.time()))
logItem.set_contents(contents)
logitemList.append(logItem)
req = PutLogsRequest(project, logstore, topic, source, logitemList)
res = client.put_logs(req)
res.log_print()