#sdk #tencent-cloud #log #content #腾讯云日志服务cls #log-group #log-producer

tencentcloud-cls-sdk-rust

腾讯云日志服务CLS SDK

7 releases

0.0.7 Jun 14, 2024
0.0.6 Jun 14, 2024

#3 in #tencent-cloud

Download history 2/week @ 2024-09-23

107 downloads per month

Apache-2.0

26KB
581 lines

腾讯云日志服务CLS RUST SDK

example usage:


use tencentcloud - cls-sdk-rust::{LogGroupList, LogGroup, Content, Log, LogProducer};

fn main() {
	// create a async runtime
	let rt = tokio::runtime::Runtime::new().unwrap();
	let producer = LogProducer::new("", "", "ap-guangzhou-open.cls.tencentcs.com").unwrap();
	
	// Create a new Log with default timestamp (now)
	let mut log: Log = Log::default();
	log.time = chrono::Local::now().timestamp_millis();
	// Push K-V pairs to Log
	log.contents.push(Content::new("level", "INFO"));
	log.contents.push(Content::new("message", "startup"));
	// Create LogGroup
	let mut log_group: LogGroup = LogGroup::default();
	log_group.source = Option::Some(Cow::from("127.0.0.1"));
	log_group.logs.push(log);
	let mut log_group_list = LogGroupList::default();
	log_group_list.logGroupList.push(log_group);
	
	let result = rt
		.block_on(producer.put_logs(
			"".to_string(),
			&log_group_list,
		))
		.unwrap();
	let text = rt.block_on(result.text()).unwrap();
	println!("{}", text);
}

Dependencies

~11–23MB
~317K SLoC