gol

package module
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 5 Imported by: 0

README

gol

Logs Viewer

View realtime logs in your fav browser
Advanced regex search
Low Mem Footprint
Single binary

Supports

Docker Container logs from path
Docker Container logs
SSH remote logs
STDIN logs
Local logs
Tar logs

  • Quick Setup: One command to install and run.

  • Hassle Free: Doesn't require elastic search or other shebang.

  • Platform: Supports (arm64, arch64, Mac, Mac M1, Ubuntu and Windows).

  • Flexible: View docker logs, remote logs over ssh, files on disk and piped inputs in browser.

  • Intelligent Smartly judges log level, and dates.

  • Search Fast search with regex.

  • Realtime Tail logs in real time in browser.

  • Log Rotation Supports log rotation and watch for new log files.

  • Embed in GO Easily embed in your existing Go app.

View in Browser

Intuitive UI to view logs in browser

gol

Reports from coveritup

gol

npm-install-time npm-build-time go-build-cli-time go-build-all-time

go-test-run-time coverage go-binary-size go-mod-dependencies

npm-install-time npm-build-time go-build-cli-time go-build-all-time go-test-run-time coverage go-binary-size go-mod-dependencies

Install using curl

Use this method if go is not installed on your server

curl -sL https://raw.githubusercontent.com/kevincobain2000/gol/master/install.sh | sh

Examples

CLI - Basic Example

# run in current directory for pattern
gol "*log" "access/*log.tar.gz"

CLI - Advanced Examples

All patterns work in combination with each other.

# search using pipe and file patterns
demsg | gol -f="/var/log/*.log"

# over ssh
# port optional (default 22), password optional (default ''), private_key optional (default $HOME/.ssh/id_rsa)
gol -s="user@host[:port] [password=/path/to/password] [private_key=/path/to/key] /app/*logs"

# Docker all container logs
gol -d=""

# Docker specific container logs
gol -d="container-id"

# Docker specific path on a container
gol -d="container-id /app/logs.log"

# All patterns combined
gol -d="container-id" \
    -d="container-id /app/logs.log" \
    -s="user@host[:port] [password=/path/to/password] [private_key=/path/to/key] /app/*logs" \
    -f="/var/log/*.log"

Embed in GO

If you don't want to use CLI to have seperate port and want to integrate within your existing Go app.

import (
	"fmt"
	"net/http"

	"github.com/kevincobain2000/gol"
)

func main() {
    // init with options of file path you want to watch
    g := gol.NewGol(func(o *gol.GolOptions) error {
        o.FilePaths = []string{"*.log"}
        return nil
    })

    // register following two routes
    http.HandleFunc("/gol/api", g.Adapter(g.NewAPIHandler().Get))
    http.HandleFunc("/gol", g.Adapter(g.NewAssetsHandler().Get))

    // start server as usual
    http.ListenAndServe("localhost:8080", nil)
}

CHANGE LOG

  • v1.0.0 - Initial release.
  • v1.0.3 - Multiple file patterns, and pipe input support.
  • v1.0.4 - Support os.Args for quick view.
  • v1.0.5 - Support ssh logs.
  • v1.0.6 - UI shows grouped output.
  • v1.0.7 - Support docker logs.
  • v1.0.14 - Sleak UI changes and support dates.
  • v1.0.17 - Support both ignore and include patterns.
  • v1.0.21 - Better logging.
  • v1.0.22 - Support UA.
  • v1.0.24 - Dropdown on files.
  • v1.0.25 - Searchable files.
  • v1.1.0 - Embed in GO, buggy.
  • v1.1.1 - Embed in GO, stable.
  • v1.1.2 - Go VUP
  • v1.1.3 - Node VUP and debounce for better performance.

Limitations

  • Docker Logs: Only supports logs from containers running on the same machine.

  • fmt, stdout: For embedded use, fmt and stdout logs are not intercepted.

    Tip: If you want to capture, then run your app by piping output as ./app >> logs.log.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gol

type Gol struct {
	Options *GolOptions
}

func NewGol

func NewGol(opts ...GolOption) *Gol

func (*Gol) Adapter

func (*Gol) Adapter(echoHandler echo.HandlerFunc) http.HandlerFunc

func (*Gol) NewAPIHandler

func (g *Gol) NewAPIHandler() *pkg.APIHandler

func (*Gol) NewAssetsHandler

func (*Gol) NewAssetsHandler() *pkg.AssetsHandler

type GolOption

type GolOption func(*GolOptions) error // nolint: revive

type GolOptions

type GolOptions struct {
	Every     int64
	FilePaths []string
	LogLevel  slog.Leveler
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL