logs

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cli.Command{
	Name:  "logs",
	Usage: "logs query",
	Action: func(ctx *cli.Context) error {
		defer xerror.RespExit()

		config := tail.Config{Follow: true}
		n := int64(0)
		if ctx.NArg() < 1 {
			fmt.Println("need one or more files as arguments")
			os.Exit(1)
		}

		mapping := bleve.NewIndexMapping()
		index, err := bleve.New("logs/bleve", mapping)
		if err == bleve.ErrorIndexPathExists {
			index, err = bleve.Open("logs/bleve")
			xerror.Panic(err)
		}

		go searchInit(index, "logs", ":8095")

		if n != 0 {
			config.Location = &tail.SeekInfo{Offset: -n, Whence: io.SeekEnd}
		}

		done := make(chan bool)
		xerror.Panic(fastwalk.FastWalk(ctx.Args().First(), func(path string, typ os.FileMode) error {
			if typ.IsDir() {
				return nil
			}

			go tailFile(index, path, config, done)

			return nil
		}))
		select {}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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