Created
January 28, 2020 04:17
-
-
Save marufeuille/e6f8ed6851d7bd49d6afa97e167d6427 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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