@@ -61,6 +61,11 @@ pub enum LogLevel {
6161 Panic ,
6262}
6363
64+ /// Sentinel value used for injected system logs.
65+ ///
66+ /// Keep this in sync with the constants in `spacetimedb_core::database_logger::Record`.
67+ const SENTINEL : & ' static str = "__spacetimedb__" ;
68+
6469/// Keep this in sync with `spacetimedb_core::database_logger::Record`.
6570#[ serde_with:: serde_as]
6671#[ derive( serde:: Deserialize ) ]
@@ -198,26 +203,36 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::E
198203 out. set_color ( & color) ?;
199204 write ! ( out, "{level:>5}: " ) ?;
200205 out. reset ( ) ?;
201- let mut need_space = false ;
206+ let mut need_space_before_filename = false ;
207+ let mut need_colon_sep = false ;
202208 let dimmed = ColorSpec :: new ( ) . set_dimmed ( true ) . clone ( ) ;
203209 if let Some ( function) = record. function {
204- out. set_color ( & dimmed) ?;
205- write ! ( out, "{function}" ) ?;
206- out. reset ( ) ?;
207- need_space = true ;
210+ if function != SENTINEL {
211+ out. set_color ( & dimmed) ?;
212+ write ! ( out, "{function}" ) ?;
213+ out. reset ( ) ?;
214+ need_space_before_filename = true ;
215+ need_colon_sep = true ;
216+ }
208217 }
209218 if let Some ( filename) = record. filename {
210- out. set_color ( & dimmed) ?;
211- if need_space {
212- write ! ( out, " " ) ?;
213- }
214- write ! ( out, "{filename}" ) ?;
215- if let Some ( line) = record. line_number {
216- write ! ( out, ":{line}" ) ?;
219+ if filename != SENTINEL {
220+ out. set_color ( & dimmed) ?;
221+ if need_space_before_filename {
222+ write ! ( out, " " ) ?;
223+ }
224+ write ! ( out, "{filename}" ) ?;
225+ if let Some ( line) = record. line_number {
226+ write ! ( out, ":{line}" ) ?;
227+ }
228+ out. reset ( ) ?;
229+ need_colon_sep = true ;
217230 }
218- out. reset ( ) ?;
219231 }
220- writeln ! ( out, ": {}" , record. message) ?;
232+ if need_colon_sep {
233+ write ! ( out, ": " ) ?;
234+ }
235+ writeln ! ( out, "{}" , record. message) ?;
221236 if let Some ( trace) = & record. trace {
222237 for frame in trace {
223238 write ! ( out, " in " ) ?;
0 commit comments