From edcc5f5b67e52453b3a42a22b6d97395153084fc Mon Sep 17 00:00:00 2001 From: sheyanjie-qq <249478495@qq.com> Date: Mon, 12 Aug 2024 19:05:01 +0800 Subject: [PATCH] improve log --- .../rust/nativeexample/examples/tmq.rs | 15 ++++++++------- docs/examples/rust/restexample/examples/tmq.rs | 6 +++--- .../com/taosdata/example/ConsumerLoopFull.java | 18 +++++++++--------- .../taosdata/example/WsConsumerLoopFull.java | 18 +++++++++--------- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/docs/examples/rust/nativeexample/examples/tmq.rs b/docs/examples/rust/nativeexample/examples/tmq.rs index 4ae71bc445..7f3bd416d1 100644 --- a/docs/examples/rust/nativeexample/examples/tmq.rs +++ b/docs/examples/rust/nativeexample/examples/tmq.rs @@ -61,7 +61,7 @@ async fn main() -> anyhow::Result<()> { // ANCHOR: consume match consumer.subscribe(["topic_meters"]).await{ - Ok(_) => println!("subscribe topics successfully."), + Ok(_) => println!("Subscribe topics successfully."), Err(err) => { eprintln!("Failed to subscribe topic_meters, dsn: {}; ErrMessage: {}", dsn, err); return Err(err.into()); @@ -123,7 +123,7 @@ async fn main() -> anyhow::Result<()> { } // commit offset manually when you have processed the message. match consumer.commit(offset).await{ - Ok(_) => println!("commit offset manually successfully."), + Ok(_) => println!("Commit offset manually successfully."), Err(err) => { eprintln!("Failed to commit offset manually, dsn: {}; ErrMessage: {}", dsn, err); return Err(err.into()); @@ -140,7 +140,7 @@ async fn main() -> anyhow::Result<()> { // ANCHOR: seek_offset let assignments = consumer.assignments().await.unwrap(); - println!("assignments: {:?}", assignments); + println!("Now assignments: {:?}", assignments); // seek offset for topic_vec_assignment in assignments { @@ -163,23 +163,24 @@ async fn main() -> anyhow::Result<()> { match consumer.offset_seek(topic, vgroup_id, begin).await{ Ok(_) => (), Err(err) => { - eprintln!("seek example failed; ErrMessage: {}", err); + eprintln!("Seek example failed; ErrMessage: {}", err); return Err(err.into()); } } } let topic_assignment = consumer.topic_assignment(topic).await; - println!("topic assignment: {:?}", topic_assignment); + println!("Topic assignment: {:?}", topic_assignment); } - println!("assignment seek to beginning successfully."); + println!("Assignment seek to beginning successfully."); // after seek offset let assignments = consumer.assignments().await.unwrap(); - println!("after seek offset assignments: {:?}", assignments); + println!("After seek offset assignments: {:?}", assignments); // ANCHOR_END: seek_offset // ANCHOR: unsubscribe consumer.unsubscribe().await; + println!("Consumer unsubscribed successfully."); // ANCHOR_END: unsubscribe tokio::time::sleep(Duration::from_secs(1)).await; diff --git a/docs/examples/rust/restexample/examples/tmq.rs b/docs/examples/rust/restexample/examples/tmq.rs index c828bd91ac..37fb9edc21 100644 --- a/docs/examples/rust/restexample/examples/tmq.rs +++ b/docs/examples/rust/restexample/examples/tmq.rs @@ -172,15 +172,15 @@ async fn main() -> anyhow::Result<()> { let topic_assignment = consumer.topic_assignment(topic).await; println!("topic assignment: {:?}", topic_assignment); } - println!("assignment seek to beginning successfully."); + println!("Assignment seek to beginning successfully."); // after seek offset let assignments = consumer.assignments().await.unwrap(); - println!("after seek offset assignments: {:?}", assignments); + println!("After seek offset assignments: {:?}", assignments); // ANCHOR_END: seek_offset // ANCHOR: unsubscribe consumer.unsubscribe().await; - println!("consumer unsubscribed successfully."); + println!("Consumer unsubscribed successfully."); // ANCHOR_END: unsubscribe tokio::time::sleep(Duration::from_secs(1)).await; diff --git a/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ConsumerLoopFull.java b/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ConsumerLoopFull.java index 39782e787c..3c0798d198 100644 --- a/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ConsumerLoopFull.java +++ b/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ConsumerLoopFull.java @@ -59,7 +59,7 @@ public class ConsumerLoopFull { // subscribe to the topics consumer.subscribe(topics); - System.out.println("subscribe topics successfully."); + System.out.println("Subscribe topics successfully."); for (int i = 0; i < 50; i++) { // poll data ConsumerRecords records = consumer.poll(Duration.ofMillis(100)); @@ -88,9 +88,9 @@ public class ConsumerLoopFull { // subscribe to the topics consumer.subscribe(topics); - System.out.println("subscribe topics successfully."); + System.out.println("Subscribe topics successfully."); Set assignment = consumer.assignment(); - System.out.println("now assignment: " + JSON.toJSONString(assignment)); + System.out.println("Now assignment: " + JSON.toJSONString(assignment)); ConsumerRecords records = ConsumerRecords.emptyRecord(); // make sure we have got some data @@ -99,13 +99,13 @@ public class ConsumerLoopFull { } consumer.seekToBeginning(assignment); - System.out.println("assignment seek to beginning successfully."); + System.out.println("Assignment seek to beginning successfully."); } catch (SQLException ex) { // handle any errors, please refer to the JDBC specifications for detailed exceptions info - System.out.println("seek example failed; ErrCode:" + ex.getErrorCode() + "; ErrMessage: " + ex.getMessage()); + System.out.println("Seek example failed; ErrCode:" + ex.getErrorCode() + "; ErrMessage: " + ex.getMessage()); throw new SQLException("seek example failed", ex); } catch (Exception ex) { - System.out.println("seek example failed; ErrMessage: " + ex.getMessage()); + System.out.println("Seek example failed; ErrMessage: " + ex.getMessage()); throw new SQLException("seek example failed", ex); } // ANCHOR_END: consumer_seek @@ -128,7 +128,7 @@ public class ConsumerLoopFull { if (!records.isEmpty()) { // after processing the data, commit the offset manually consumer.commitSync(); - System.out.println("commit offset manually successfully."); + System.out.println("Commit offset manually successfully."); } } } catch (SQLException ex) { @@ -149,7 +149,7 @@ public class ConsumerLoopFull { try { // unsubscribe the consumer consumer.unsubscribe(); - System.out.println("consumer unsubscribed successfully."); + System.out.println("Consumer unsubscribed successfully."); } catch (SQLException ex) { // handle any errors, please refer to the JDBC specifications for detailed exceptions info System.out.println("Failed to unsubscribe consumer. ErrCode:" + ex.getErrorCode() + "; ErrMessage: " + ex.getMessage()); @@ -161,7 +161,7 @@ public class ConsumerLoopFull { finally { // close the consumer consumer.close(); - System.out.println("consumer closed successfully."); + System.out.println("Consumer closed successfully."); } // ANCHOR_END: unsubscribe_data_code_piece } diff --git a/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/WsConsumerLoopFull.java b/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/WsConsumerLoopFull.java index 45767f8461..d7207ffe71 100644 --- a/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/WsConsumerLoopFull.java +++ b/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/WsConsumerLoopFull.java @@ -57,7 +57,7 @@ public class WsConsumerLoopFull { // subscribe to the topics consumer.subscribe(topics); - System.out.println("subscribe topics successfully."); + System.out.println("Subscribe topics successfully."); for (int i = 0; i < 50; i++) { // poll data ConsumerRecords records = consumer.poll(Duration.ofMillis(100)); @@ -86,9 +86,9 @@ public class WsConsumerLoopFull { // subscribe to the topics consumer.subscribe(topics); - System.out.println("subscribe topics successfully."); + System.out.println("Subscribe topics successfully."); Set assignment = consumer.assignment(); - System.out.println("now assignment: " + JSON.toJSONString(assignment)); + System.out.println("Now assignment: " + JSON.toJSONString(assignment)); ConsumerRecords records = ConsumerRecords.emptyRecord(); // make sure we have got some data @@ -97,13 +97,13 @@ public class WsConsumerLoopFull { } consumer.seekToBeginning(assignment); - System.out.println("assignment seek to beginning successfully."); + System.out.println("Assignment seek to beginning successfully."); } catch (SQLException ex) { // handle any errors, please refer to the JDBC specifications for detailed exceptions info - System.out.println("seek example failed; ErrCode:" + ex.getErrorCode() + "; ErrMessage: " + ex.getMessage()); + System.out.println("Seek example failed; ErrCode:" + ex.getErrorCode() + "; ErrMessage: " + ex.getMessage()); throw new SQLException("seek example failed", ex); } catch (Exception ex) { - System.out.println("seek example failed; ErrMessage: " + ex.getMessage()); + System.out.println("Seek example failed; ErrMessage: " + ex.getMessage()); throw new SQLException("seek example failed", ex); } // ANCHOR_END: consumer_seek @@ -126,7 +126,7 @@ public class WsConsumerLoopFull { if (!records.isEmpty()) { // after processing the data, commit the offset manually consumer.commitSync(); - System.out.println("commit offset manually successfully."); + System.out.println("Commit offset manually successfully."); } } } catch (SQLException ex) { @@ -147,7 +147,7 @@ public class WsConsumerLoopFull { try { // unsubscribe the consumer consumer.unsubscribe(); - System.out.println("consumer unsubscribed successfully."); + System.out.println("Consumer unsubscribed successfully."); } catch (SQLException ex) { // handle any errors, please refer to the JDBC specifications for detailed exceptions info System.out.println("Failed to unsubscribe consumer. ErrCode:" + ex.getErrorCode() + "; ErrMessage: " + ex.getMessage()); @@ -159,7 +159,7 @@ public class WsConsumerLoopFull { finally { // close the consumer consumer.close(); - System.out.println("consumer closed successfully."); + System.out.println("Consumer closed successfully."); } // ANCHOR_END: unsubscribe_data_code_piece }