Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nevinpuri committed Feb 11, 2023
1 parent 77382b8 commit 215ae9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Example request body
```json
{
"timestamp": "1675955819",
"level": "debug",
"service": "my_service",
"key": "value",
"data": {
Expand All @@ -36,6 +37,17 @@ Example request body

Library specific examples coming soon

## Querying Logs

The ErLog DB is literally just an sqlite file, so you can open it with any sqlite3 client. You can use any of sqlite3's [JSON](https://www.sqlite.org/json1.html) functions to query the `data` column in the `er_log` table.

Example:

```bash
sqlite> select COUNT(*) from er_logs where json_extract(data, "$.level") = "error";
56
```
## How does it work?
ErLog is just an api which batch inserts data efficiently into an sqlite3 server.
Expand Down
9 changes: 3 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ import (
"fmt"
"io/ioutil"
"net/http"
"time"

"github.com/gin-contrib/cors"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"

"erlog/models"
"erlog/netlogger"
"erlog/queue"

"github.com/gin-gonic/gin"
Expand All @@ -32,23 +29,23 @@ func main() {
models.Connect()

queue := queue.New(512, 3000)
log.Logger = zerolog.New(netlogger.New()).With().Logger()
// log.Logger = zerolog.New(netlogger.New()).With().Logger()

go queue.Run()

// todo: make queue take channel and return OK when it's started running
// so we can block here and wait for the queue to start


// /*
/*
go func() {
time.Sleep(time.Second * 2)
fmt.Println("Starting")
for i := 0; i < 4; i++ {
log.Print("good log")
}
}()
// */
*/


r := gin.Default()
Expand Down

0 comments on commit 215ae9b

Please sign in to comment.