Skip to main content

netget/logging/
patterns.rs

1//! Shared log pattern constants
2//!
3//! These constants are used both for logging and for test assertions.
4//! When a log pattern changes, the tests that wait for it automatically update.
5//!
6//! ## Usage in Code
7//! ```ignore
8//! info!("{} {} connected to {}", patterns::TCP_CLIENT, client_id, remote_addr);
9//! ```
10//!
11//! ## Usage in Tests
12//! ```ignore
13//! client.wait_for_pattern(patterns::TCP_CLIENT_CONNECTED, Duration::from_secs(5)).await?;
14//! ```
15
16// Client patterns - TCP
17pub const TCP_CLIENT: &str = "TCP client";
18pub const TCP_CLIENT_CONNECTED: &str = "connected to";
19pub const TCP_CLIENT_SENT: &str = "bytes after connect";
20pub const TCP_CLIENT_RECEIVED: &str = "bytes from server";
21pub const TCP_CLIENT_DISCONNECTED: &str = "disconnected";
22
23// Client patterns - TLS
24pub const TLS_CLIENT: &str = "TLS client";
25pub const TLS_CLIENT_CONNECTED: &str = "connected to";
26pub const TLS_CLIENT_SENT: &str = "bytes after connect";
27pub const TLS_CLIENT_RECEIVED: &str = "bytes from server";
28pub const TLS_CLIENT_DISCONNECTED: &str = "disconnected";
29
30// Client patterns - Telnet
31pub const TELNET_CLIENT: &str = "Telnet client";
32pub const TELNET_CLIENT_CONNECTED: &str = "connected to";
33pub const TELNET_CLIENT_SENT_COMMAND: &str = "Sent Telnet command after connect:";
34pub const TELNET_CLIENT_SENT_TEXT: &str = "Sent Telnet text after connect:";
35pub const TELNET_CLIENT_RECEIVED: &str = "received";
36pub const TELNET_CLIENT_DISCONNECTED: &str = "disconnected";
37
38// Client patterns - Redis
39pub const REDIS_CLIENT: &str = "Redis client";
40pub const REDIS_CLIENT_CONNECTED: &str = "connected to";
41pub const REDIS_CLIENT_SENT_COMMAND: &str = "Sent Redis command after connect:";
42pub const REDIS_CLIENT_RECEIVED: &str = "received:";
43pub const REDIS_CLIENT_DISCONNECTED: &str = "disconnected";
44
45// Client patterns - HTTP
46pub const HTTP_CLIENT_CONNECTED: &str = "HTTP client";
47
48// Client patterns - AMQP
49pub const AMQP_CLIENT_CONNECTED: &str = "AMQP client";
50
51// Server patterns - TCP
52//
53// The "(action-based)" qualifier was dropped from these startup lines long ago
54// and the constants were never updated, so every test waiting on one sat out its
55// full timeout and then failed somewhere else entirely. `tests/log_patterns_test.rs`
56// now fails the build on a constant that matches no log line.
57pub const TCP_SERVER_LISTENING: &str = "TCP server listening on";
58pub const TCP_SERVER_RECEIVED: &str = "TCP received";
59pub const TCP_SERVER_CONNECTION_CLOSED: &str = "Connection";
60
61// Server patterns - Telnet
62pub const TELNET_SERVER_LISTENING: &str = "Telnet server listening on";
63
64// Server patterns - Redis
65pub const REDIS_SERVER_LISTENING: &str = "Redis server listening on";
66
67// Server patterns - HTTP
68//
69// The HTTP server names itself from its TLS mode ("HTTP"/"HTTPS server listening
70// on ..."), so the shared suffix is the whole matchable part.
71pub const HTTP_SERVER_LISTENING: &str = "server listening on";
72
73// TELNET_SERVER_RECEIVED, REDIS_SERVER_RECEIVED and HTTP_SERVER_REQUEST used to
74// live here. They described per-request lines that no longer exist in any form:
75// that detail moved to the protocols' event log templates, and the per-read
76// summaries are DEBUG/Sink::FileOnly so they never reach the status stream a test
77// observes. Nothing referenced them. A pattern that cannot match is worse than an
78// absent one — it turns "this never happened" into a timeout somewhere unrelated.
79
80// General patterns
81pub const SERVER_STARTUP: &str = "Starting server";
82pub const CLIENT_STARTUP: &str = "Starting client";
83pub const CONVERSATION_STATE_UPDATED: &str = "Updated conversation state";