https://github.com/ichtrojan/horus
HTTP request logger for Golang
https://github.com/ichtrojan/horus
go golang logging
Last synced: 11 months ago
JSON representation
HTTP request logger for Golang
- Host: GitHub
- URL: https://github.com/ichtrojan/horus
- Owner: ichtrojan
- License: mit
- Created: 2021-02-21T15:30:06.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-04-02T16:28:33.000Z (about 4 years ago)
- Last Synced: 2024-06-18T20:16:05.197Z (about 2 years ago)
- Topics: go, golang, logging
- Language: Go
- Homepage:
- Size: 6.17 MB
- Stars: 87
- Watchers: 5
- Forks: 15
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Horus 𓂀

## Introduction
Horus is a request logger and viewer for [Go](https://golang.org). It allows developers log and view http requests made to their web application.

## Installation
Run the following command to install Horus on your project:
```bash
go get github.com/ichtrojan/horus
```
### Initiate horus
```go
package main
import github.com/ichtrojan/horus
func main() {
listener, err := horus.Init("mysql", horus.Config{
DbName: "{preferred_database_name}",
DbHost: "{preferred_database_host}",
DbPssword: "{preferred_database_password}",
DbPort: "{preferred_database_port}",
DbUser: "{preferred_database_user}",
})
}
```
>**NOTE**
> Supported database adapters include **mysql** and **postgres**
### Serve dashboard (optional)

```go
...
if err := listener.Serve(":8081", "{preferred_password}")); err != nil {
log.Fatal(err)
}
...
```
>**NOTE**
> Visit `/horus` on the port configured to view the dashboard
### Usage
To enable horus to listen for requests, use the `Watch` middleware provided by horus on the endpoints you will like monitor.
```go
...
http.HandleFunc("/", listener.Watch(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
response := map[string]string{"message": "Horus is live 👁"}
_ = json.NewEncoder(w).Encode(response)
}))
...
```
You can explore the implementation in the [example folder](https://github.com/ichtrojan/horus/tree/main/example).
## Built by
* Toni Akinmolayan - [twitter](https://twitter.com/toniastro_) [GitHub](https://github.com/toniastro)
* Michael Trojan Okoh - [twitter](https://twitter.com/ichtrojan) [GitHub](https://github.com/ichtrojan)