feat: don't log file browser completion messages
This commit is contained in:
		
							parent
							
								
									e752e8a405
								
							
						
					
					
						commit
						67f49110dc
					
				
					 2 changed files with 16 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -265,7 +265,7 @@ pub fn Create(options: type) type {
 | 
			
		|||
            } else {
 | 
			
		||||
                try self.construct_path(self.query.items, self.entries.items[self.complete_trigger_count - 1], self.complete_trigger_count - 1);
 | 
			
		||||
            }
 | 
			
		||||
            log.logger("file_browser").print("{d}/{d}", .{ self.matched_entry + 1, self.entries.items.len });
 | 
			
		||||
            message("{d}/{d}", .{ self.matched_entry + 1, self.entries.items.len });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        fn construct_path(self: *Self, path_: []const u8, entry: Entry, entry_no: usize) !void {
 | 
			
		||||
| 
						 | 
				
			
			@ -300,7 +300,7 @@ pub fn Create(options: type) type {
 | 
			
		|||
                try self.construct_path(self.query.items, entry, last_no);
 | 
			
		||||
                self.complete_trigger_count = matched;
 | 
			
		||||
            } else {
 | 
			
		||||
                log.logger("file_browser").print("no match for '{s}'", .{self.match.items});
 | 
			
		||||
                message("no match for '{s}'", .{self.match.items});
 | 
			
		||||
                try self.construct_path(self.query.items, .{ .name = self.match.items, .type = .file }, 0);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -322,5 +322,10 @@ pub fn Create(options: type) type {
 | 
			
		|||
                self.file_path.clearRetainingCapacity();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        fn message(comptime fmt: anytype, args: anytype) void {
 | 
			
		||||
            var buf: [256]u8 = undefined;
 | 
			
		||||
            tp.self_pid().send(.{ "message", std.fmt.bufPrint(&buf, fmt, args) catch @panic("too large") }) catch {};
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -83,6 +83,9 @@ fn receive_log(self: *Self, _: tp.pid_ref, m: tp.message) MessageFilter.Error!bo
 | 
			
		|||
        try logview.process_log(m);
 | 
			
		||||
        try self.process_log(m);
 | 
			
		||||
        return true;
 | 
			
		||||
    } else if (try cbor.match(m.buf, .{ "message", tp.more })) {
 | 
			
		||||
        try self.process_message(m);
 | 
			
		||||
        return true;
 | 
			
		||||
    } else if (try cbor.match(m.buf, .{ "MINILOG", tp.extract(&clear_msg_num) })) {
 | 
			
		||||
        if (clear_msg_num == self.msg_counter)
 | 
			
		||||
            self.clear();
 | 
			
		||||
| 
						 | 
				
			
			@ -114,6 +117,12 @@ fn process_log(self: *Self, m: tp.message) MessageFilter.Error!void {
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn process_message(self: *Self, m: tp.message) MessageFilter.Error!void {
 | 
			
		||||
    var msg: []const u8 = undefined;
 | 
			
		||||
    if (try cbor.match(m.buf, .{ tp.string, tp.extract(&msg) }))
 | 
			
		||||
        try self.set(msg, .info);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn update_clear_timer(self: *Self) !void {
 | 
			
		||||
    self.msg_counter += 1;
 | 
			
		||||
    const delay = std.time.us_per_s * @as(u64, if (self.level == .err) error_display_time_seconds else message_display_time_seconds);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue