@@ -14,9 +14,45 @@ pub struct NetworkLogsView {
1414
1515impl NetworkLogsView {
1616 pub fn new ( _window : & mut Window , _cx : & mut Context < Self > ) -> Self {
17- Self {
18- logs : VecDeque :: new ( ) ,
19- }
17+ // Add some sample logs for demonstration
18+ let mut logs = VecDeque :: new ( ) ;
19+
20+ logs. push_back ( LogEntry {
21+ timestamp : "2025-11-10 15:00:01" . to_string ( ) ,
22+ level : LogLevel :: Info ,
23+ target : "wsrx::daemon" . to_string ( ) ,
24+ message : "Daemon started successfully" . to_string ( ) ,
25+ } ) ;
26+
27+ logs. push_back ( LogEntry {
28+ timestamp : "2025-11-10 15:00:05" . to_string ( ) ,
29+ level : LogLevel :: Debug ,
30+ target : "wsrx::tunnel" . to_string ( ) ,
31+ message : "Initializing WebSocket connection to ws://example.com" . to_string ( ) ,
32+ } ) ;
33+
34+ logs. push_back ( LogEntry {
35+ timestamp : "2025-11-10 15:00:10" . to_string ( ) ,
36+ level : LogLevel :: Info ,
37+ target : "wsrx::tunnel" . to_string ( ) ,
38+ message : "Connection established: 127.0.0.1:8080 → ws://example.com" . to_string ( ) ,
39+ } ) ;
40+
41+ logs. push_back ( LogEntry {
42+ timestamp : "2025-11-10 15:00:15" . to_string ( ) ,
43+ level : LogLevel :: Warn ,
44+ target : "wsrx::proxy" . to_string ( ) ,
45+ message : "High latency detected: 250ms" . to_string ( ) ,
46+ } ) ;
47+
48+ logs. push_back ( LogEntry {
49+ timestamp : "2025-11-10 15:00:20" . to_string ( ) ,
50+ level : LogLevel :: Error ,
51+ target : "wsrx::tunnel" . to_string ( ) ,
52+ message : "Connection failed: Connection refused" . to_string ( ) ,
53+ } ) ;
54+
55+ Self { logs }
2056 }
2157
2258 fn log_level_color ( & self , level : LogLevel ) -> gpui:: Rgba {
@@ -128,22 +164,45 @@ impl Render for NetworkLogsView {
128164 . child ( "Network Logs" ) ,
129165 )
130166 . child (
131- div ( ) . flex ( ) . gap_2 ( ) . child (
132- div ( )
133- . id ( "clear-logs-button" )
134- . px_3 ( )
135- . py_1 ( )
136- . text_sm ( )
137- . bg ( gpui:: rgba ( 0x444444FF ) )
138- . rounded_md ( )
139- . cursor_pointer ( )
140- . hover ( |div| div. bg ( gpui:: rgba ( 0x555555FF ) ) )
141- . on_click ( cx. listener ( |this, _event, _window, cx| {
142- this. logs . clear ( ) ;
143- cx. notify ( ) ;
144- } ) )
145- . child ( "Clear" ) ,
146- ) ,
167+ div ( ) . flex ( ) . gap_2 ( )
168+ . child (
169+ div ( )
170+ . id ( "add-sample-log-button" )
171+ . px_3 ( )
172+ . py_1 ( )
173+ . text_sm ( )
174+ . bg ( colors:: accent ( ) )
175+ . rounded_md ( )
176+ . cursor_pointer ( )
177+ . hover ( |div| div. bg ( gpui:: rgba ( 0x0088DDFF ) ) )
178+ . on_click ( cx. listener ( |this, _event, _window, cx| {
179+ use chrono:: Local ;
180+ this. logs . push_back ( LogEntry {
181+ timestamp : Local :: now ( ) . format ( "%Y-%m-%d %H:%M:%S" ) . to_string ( ) ,
182+ level : LogLevel :: Info ,
183+ target : "wsrx::test" . to_string ( ) ,
184+ message : format ! ( "Sample log entry #{}" , this. logs. len( ) + 1 ) ,
185+ } ) ;
186+ cx. notify ( ) ;
187+ } ) )
188+ . child ( "Add Sample" ) ,
189+ )
190+ . child (
191+ div ( )
192+ . id ( "clear-logs-button" )
193+ . px_3 ( )
194+ . py_1 ( )
195+ . text_sm ( )
196+ . bg ( gpui:: rgba ( 0x444444FF ) )
197+ . rounded_md ( )
198+ . cursor_pointer ( )
199+ . hover ( |div| div. bg ( gpui:: rgba ( 0x555555FF ) ) )
200+ . on_click ( cx. listener ( |this, _event, _window, cx| {
201+ this. logs . clear ( ) ;
202+ cx. notify ( ) ;
203+ } ) )
204+ . child ( "Clear" ) ,
205+ ) ,
147206 ) ,
148207 )
149208 . child ( if self . logs . is_empty ( ) {
0 commit comments