MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / tail_n

Function tail_n

crates/core/src/database_logger.rs:728–761  ·  view source on GitHub ↗

Test calling [DatabaseLogger::tail] with `Some(n)`. Like `tail -n`.

(logger: DatabaseLogger)

Source from the content-addressed store, hash-verified

726 ///
727 /// Like `tail -n`.
728 async fn tail_n(logger: DatabaseLogger) {
729 let logger = Arc::new(logger);
730
731 write_logs(logger.clone(), 0..10).await;
732
733 let a = logger
734 .tail(Some(10), false)
735 .await
736 .unwrap()
737 .try_collect::<BytesMut>()
738 .await
739 .unwrap();
740 let b = logger
741 .tail(None, false)
742 .await
743 .unwrap()
744 .try_collect::<BytesMut>()
745 .await
746 .unwrap();
747 assert_eq!(a, b);
748
749 let c = logger
750 .tail(Some(5), false)
751 .await
752 .unwrap()
753 .try_collect::<BytesMut>()
754 .await
755 .unwrap();
756 let json_logs = deserialize_logs(&c).unwrap();
757
758 assert_eq!(json_logs.len(), 5);
759 assert_eq!(json_logs[0].message, "log line 5");
760 assert_eq!(json_logs[4].message, "log line 9");
761 }
762
763 /// Test calling [DatabaseLogger::tail] with
764 /// `follow = true`.

Callers

nothing calls this directly

Calls 7

write_logsFunction · 0.85
deserialize_logsFunction · 0.85
with_file_loggerFunction · 0.85
tailMethod · 0.80
newFunction · 0.50
cloneMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…