mirror of
https://github.com/taigrr/log-socket
synced 2026-03-20 16:02:28 -07:00
41aad10e6cf4fcaa800bc35b4e500c1d1317316d
Log Socket
A real-time log viewer with WebSocket support, written in Go. This tool provides a web-based interface for viewing and filtering logs in real-time.
Features
- Real-time log streaming via WebSocket
- Web-based log viewer with filtering capabilities
- Support for multiple log levels (TRACE, DEBUG, INFO, WARN, ERROR, PANIC, FATAL)
- Color-coded log levels for better visibility
- Auto-scrolling with toggle option
- Log download functionality
- Log clearing capability
- File source tracking for each log entry
Installation
go install github.com/taigrr/log-socket@latest
Example Preview
-
Start the server:
log-socketBy default, the server runs on
0.0.0.0:8080. You can specify a different address using the-addrflag:log-socket -addr localhost:8080 -
Open your browser and navigate to
http://localhost:8080
Logging Interface
The package provides a comprehensive logging interface with the following methods:
Trace/Tracef/Traceln: For trace-level loggingDebug/Debugf/Debugln: For debug-level loggingInfo/Infof/Infoln: For info-level loggingNotice/Noticef/Noticeln: For notice-level loggingWarn/Warnf/Warnln: For warning-level loggingError/Errorf/Errorln: For error-level loggingPanic/Panicf/Panicln: For panic-level loggingFatal/Fatalf/Fatalln: For fatal-level logging
Web Interface Features
- Filtering: Type in the search box to filter logs
- Auto-scroll: Toggle auto-scrolling with the checkbox
- Download: Save all logs as a JSON file
- Clear: Remove all logs from the viewer
- Color Coding: Different log levels are color-coded for easy identification
Dependencies
- gorilla/websocket for WebSocket support
Notes
The web interface is not meant to be used as-is. It functions perfectly well for some scenarios, but it is broken out into a different package intentionally, such that users can add their own as they see fit. It's mostly here to provide an example of how to consume the websocket data and display it.
Languages
Go
79.9%
HTML
20.1%
