from aliyun.log import * | |
from aliyun.log.util import base64_encodestring | |
# アップロード用の関数を定義 | |
def put_logs(client, project, logstore, contents, compress=False): | |
topic = '' | |
source = '' | |
logitemList = [] # LogItem list | |
for c in contents: | |
logItem = LogItem() | |
logItem.set_time(int(time.time())) | |
logItem.set_contents(c) | |
logitemList.append(logItem) | |
request = PutLogsRequest(project, logstore, topic, source, logitemList, compress=compress) | |
response = client.put_logs(request) | |
response.log_print() | |
# 必要な情報を設定 | |
endpoint = 'ap-northeast-1.log.aliyuncs.com' # CHANGE YOUR ENDPOINT | |
accessKeyId = 'YOUR_ACCESSKEY' | |
accessKeySecret = 'YOUR_ACCESSKEY_SECRET' | |
logstore = 'YOUR_LOGSTORE_NAME' | |
project = 'YOUR_PROJECT_NAME' | |
client = LogClient(endpoint, accessKeyId, accessKeySecret) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment