https://github.com/rammyblog/logviz
HTTP request logger dashboard for Golang
https://github.com/rammyblog/logviz
alpinejs go golang logging
Last synced: about 1 year ago
JSON representation
HTTP request logger dashboard for Golang
- Host: GitHub
- URL: https://github.com/rammyblog/logviz
- Owner: rammyblog
- License: mit
- Created: 2024-03-22T22:17:56.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-27T21:31:09.000Z (about 2 years ago)
- Last Synced: 2025-04-30T07:05:03.062Z (about 1 year ago)
- Topics: alpinejs, go, golang, logging
- Language: Go
- Homepage:
- Size: 52.7 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# LogViz
This Go package offers a request logging and viewing system designed for web applications built with frameworks like Chi or Gin. It enables developers to log and review HTTP requests sent to their applications, aiding in debugging and monitoring processes.

## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)
## Installation
Run the following command to install Horus on your project:
```bash
go get github.com/rammyblog/logviz
```

## Usage
```
package main
import (
"fmt"
"log"
"net/http"
"time"
"github.com/rammyblog/logviz"
)
// Example handler
func HelloHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
time.Sleep(2 * time.Millisecond)
w.WriteHeader(http.StatusBadGateway)
w.Write([]byte("Hello world"))
}
func SecondHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusBadGateway)
w.Write([]byte("second handler"))
}
func main() {
// Create a new ServeMux
mux := http.NewServeMux()
reqLogger, err := logviz.Init("postgres", logviz.DbConfig{
DbUser: "postgres",
DbPassword: "password",
DbHost: "localhost",
DbName: "logviz",
DbPort: "5429",
})
if err != nil {
fmt.Println(err)
}
reqLogger.Serve(":5009")
mux.Handle("/", reqLogger.Logger(http.HandlerFunc(HelloHandler)))
mux.Handle("/second", reqLogger.Logger(http.HandlerFunc(SecondHandler)))
// Start the server
log.Println("Server started on :8080")
log.Fatal(http.ListenAndServe(":8080", mux))
}
```
Then visit the site on `http://localhost:` to view the logs
It only supports Postgres and MySQL for now, but support for other databases will be added soon.
## Contributing:
Contributions are welcome! Feel free to open issues or pull requests for bug fixes, enhancements, or new features
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details