Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nidorx committed Oct 4, 2024
1 parent 8a963ca commit 6e8ad79
Show file tree
Hide file tree
Showing 11 changed files with 340 additions and 97 deletions.
37 changes: 17 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,18 @@
</p>
</div>

**SQLog** is a **Golang** library that leverages the power of **slog** to streamline log management in a simple and efficient way.
**SQLog** is a **Golang** library that simplifies log management using **slog**. **SQLog** offers a lightweight and reliable solution for logging, making it perfect for developers seeking a cost-effective, high-performance way to monitor their applications.

One of its key advantages is its integration with **SQLite**, an embedded database, meaning there's no need for an external database server setup. This reduces operational costs and drastically simplifies system maintenance, as everything runs **embedded**, without complex dependencies.
It integrates with **SQLite**, so no external database setup is required. This keeps operations simple and reduces costs, as everything runs **embedded**.

With **SQLog**, you get a lightweight and robust solution for securely logging and storing data. It's ideal for developers looking for a practical, cost-effective, and reliable way to monitor their applications, without sacrificing performance.

## Requirements

The builtin SQLite storage uses the package `github.com/mattn/go-sqlite3`, which is a cgo package, so you need `gcc`.

See the link for more details: [https://github.com/mattn/go-sqlite3?tab=readme-ov-file#installation](https://github.com/mattn/go-sqlite3?tab=readme-ov-file#installation)

## Usage

Below is an example of using **SQLog** with the SQLite storage, with the interface exposed on port `8080`. When you access `http://localhost:8080?msg=test`, any query parameter will be sent to the log.

You can view the generated logs at `http://localhost:8080/logs/`.

> **Demo** You can see a [complete example in the demo directory](./demo/).
```go
import (
"log/slog"
Expand Down Expand Up @@ -80,27 +72,27 @@ func main() {

## Demo

[SQLog-demo.webm](https://github.com/user-attachments/assets/046b65c9-dd36-4779-8b15-915be5f7e3f3)

There is a test project in the [demo directory](./demo/).
You can view the current version of the SQLog demo at the links below:

The demo project captures all mouse movements and sends them to the server, which logs the received parameters.

You can also view the current version of the SQLog demo at the links below:
- **Log generator**: https://sqlog-demo.onrender.com/
- **SQLog UI** : https://sqlog-demo.onrender.com/logs/

> **IMPORTANT**! I am using the [free version of Render](https://docs.render.com/free), so there is no guarantee of service stability or availability.
[SQLog-demo.webm](https://github.com/user-attachments/assets/046b65c9-dd36-4779-8b15-915be5f7e3f3)

The source code is in the [demo directory](./demo/).

- Log generator (see console): https://sqlog-demo.onrender.com/
- **SQLog** UI: https://sqlog-demo.onrender.com/logs/


<div align="center">
<img src="./docs/ui.png" />
</div>


> **IMPORTANT**! I am using the [free version of Render](https://docs.render.com/free), so there is no guarantee of service stability or availability.

## How it works
## How SQLog works?

<div align="center">
<img src="./docs/diagram.png" />
Expand Down Expand Up @@ -134,6 +126,11 @@ You can also view the current version of the SQLog demo at the links below:

The combination of these layers makes **SQLog** a robust and efficient solution for log management, optimizing performance through a non-blocking architecture and the use of atomic operations. This results in fast, real-time log capture capable of handling high workloads without compromising efficiency.

## Requirements

The builtin SQLite storage uses the package `github.com/mattn/go-sqlite3`, which is a cgo package, so you need `gcc`.

See the link for more details: [https://github.com/mattn/go-sqlite3?tab=readme-ov-file#installation](https://github.com/mattn/go-sqlite3?tab=readme-ov-file#installation)

## @TODO/IDEAS/ROADMAP

Expand Down
16 changes: 16 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# SQLog Demo



You can view the current version of the SQLog demo at the links below:

The demo project captures all mouse movements and sends them to the server, which logs the received parameters.

- **Log generator**: https://sqlog-demo.onrender.com/
- **SQLog UI** : https://sqlog-demo.onrender.com/logs/

> **IMPORTANT**! I am using the [free version of Render](https://docs.render.com/free), so there is no guarantee of service stability or availability.
[SQLog-demo.webm](https://github.com/user-attachments/assets/046b65c9-dd36-4779-8b15-915be5f7e3f3)


<div align="center">
<img src="./../docs/ui.png" />
</div>





## Build Docker
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import (
"path"
"strings"

// "sqlog"

"github.com/nidorx/sqlog"
"github.com/nidorx/sqlog/sqlite"
)

var (
dev = false
dev = true

log sqlog.Log

Expand Down
2 changes: 1 addition & 1 deletion expr_parse_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type exprParseState[E any] struct {
func (s *exprParseState[E]) addOperator() {
if s.dirty {
if s.operator == "" {
s.builder.Operator("OR")
s.builder.Operator("AND")
} else {
s.builder.Operator(s.operator)
}
Expand Down
10 changes: 5 additions & 5 deletions expr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ func Test_ExprBasic(t *testing.T) {
},
{
"hello world",
[]any{"msg", "LIKE", "hello", "OR", "msg", "LIKE", "world"},
[]any{"msg", "LIKE", "hello", "AND", "msg", "LIKE", "world"},
},
{
"hello* *world",
[]any{"msg", "LIKE", "hello*", "OR", "msg", "LIKE", "*world"},
[]any{"msg", "LIKE", "hello*", "AND", "msg", "LIKE", "*world"},
},
{
`"hello world"`,
Expand All @@ -112,11 +112,11 @@ func Test_ExprBasic(t *testing.T) {
},
{
"field:hello world",
[]any{"field", "LIKE", "hello", "OR", "msg", "LIKE", "world"},
[]any{"field", "LIKE", "hello", "AND", "msg", "LIKE", "world"},
},
{
"field:hello* *world",
[]any{"field", "LIKE", "hello*", "OR", "msg", "LIKE", "*world"},
[]any{"field", "LIKE", "hello*", "AND", "msg", "LIKE", "*world"},
},
{
`field:"hello world"`,
Expand Down Expand Up @@ -229,7 +229,7 @@ func Test_ExprBoolean(t *testing.T) {
[]any{"field", "LIKE", "hello", "OR", "msg", "LIKE", "world"},
},
{
"hello AND (beautiful world)",
"hello AND (beautiful OR world)",
[]any{"msg", "LIKE", "hello", "AND", "(", "msg", "LIKE", "beautiful", "OR", "msg", "LIKE", "world", ")"},
},
{
Expand Down
5 changes: 4 additions & 1 deletion sqlite/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# SQLite Storage for SQLog
# SQLite Storage for SQLog


@TODO: Docs
10 changes: 5 additions & 5 deletions sqlite/expr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func Test_ExprBasic(t *testing.T) {
},
{
"hello world",
"json_extract(e.content, ?) GLOB ? OR json_extract(e.content, ?) GLOB ?",
"json_extract(e.content, ?) GLOB ? AND json_extract(e.content, ?) GLOB ?",
[]any{"$.msg", "*hello*", "$.msg", "*world*"},
},
{
"hello* *world",
"json_extract(e.content, ?) GLOB ? OR json_extract(e.content, ?) GLOB ?",
"json_extract(e.content, ?) GLOB ? AND json_extract(e.content, ?) GLOB ?",
[]any{"$.msg", "hello*", "$.msg", "*world"},
},
{
Expand Down Expand Up @@ -65,12 +65,12 @@ func Test_ExprBasic(t *testing.T) {
},
{
"field:hello world",
"json_extract(e.content, ?) GLOB ? OR json_extract(e.content, ?) GLOB ?",
"json_extract(e.content, ?) GLOB ? AND json_extract(e.content, ?) GLOB ?",
[]any{"$.field", "*hello*", "$.msg", "*world*"},
},
{
"field:hello* *world",
"json_extract(e.content, ?) GLOB ? OR json_extract(e.content, ?) GLOB ?",
"json_extract(e.content, ?) GLOB ? AND json_extract(e.content, ?) GLOB ?",
[]any{"$.field", "hello*", "$.msg", "*world"},
},
{
Expand Down Expand Up @@ -205,7 +205,7 @@ func Test_ExprBoolean(t *testing.T) {
[]any{"$.field", "*hello*", "$.msg", "*world*"},
},
{
"hello AND (beautiful world)",
"hello AND (beautiful OR world)",
`json_extract(e.content, ?) GLOB ? AND (json_extract(e.content, ?) GLOB ? OR json_extract(e.content, ?) GLOB ?)`,
[]any{"$.msg", "*hello*", "$.msg", "*beautiful*", "$.msg", "*world*"},
},
Expand Down
Loading

0 comments on commit 6e8ad79

Please sign in to comment.