tencentcloud-cls-sdk-rust

Crates.iotencentcloud-cls-sdk-rust
lib.rstencentcloud-cls-sdk-rust
version0.0.7
sourcesrc
created_at2024-06-12 07:12:34.141071
updated_at2024-06-14 06:51:36.596291
description腾讯云日志服务CLS SDK
homepage
repository
max_upload_size
id1269321
size38,844
Farmerx (farmerx)

documentation

README

腾讯云日志服务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);
}
Commit count: 0

cargo fmt