Skip to content

Instantly share code, notes, and snippets.

@marufeuille
Created January 28, 2020 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marufeuille/e6f8ed6851d7bd49d6afa97e167d6427 to your computer and use it in GitHub Desktop.
Save marufeuille/e6f8ed6851d7bd49d6afa97e167d6427 to your computer and use it in GitHub Desktop.
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