项目作者: tdecker91

项目描述 :
Websocket logging service.
高级语言: Go
项目地址: git://github.com/tdecker91/gowl.git
创建时间: 2018-03-02T00:29:44Z
项目社区:https://github.com/tdecker91/gowl

开源协议:

下载


GOWL Golang Websocket Logger

This is a simple service that will take in log messages from a websocket and log them.

Running

clone the repository
go get github.com/tdecker91/gowl

run the binary
./{GOPATH}/bin/gowl

GOWL will listen on port 8030 by default for websocket connections. It listens for json message formatted like the example below. Once it receives a message it will log it.

  1. {
  2. "message": "the log message",
  3. "level": "info"
  4. }

Example output

  1. [INFO] 2006-01-02 15:04:05: the log message

Log levels

Supported levels are debug, info, warn, error. Error will be printed to os.Stderr and everything else will be printed to os.Stdout

Optional flags

GOWL defaults can be overridden with command line flags. Here is an example of running GOWL on a different port with a different message format.
gowl -port=9990 -format="(%L): [%M]"

Flag Default Description
format [%L] %D: %M Message format. %L = log level. %D = Date. %M = Message. Only used for the text formatter
formatter text gowl uses logrus as the underlying logging system. use formatter=json to output messages as json
level info used to set the log level that will be printed. level supported are debug, info, warn, error
port 8030 the port gowl will listen on for websocket connections
route / the route the websocket server will listen for. For example if route is set to “/messages” then clients should connect to “ws://{address}:{port}/messages”
timeFormat “2006-01-02 15:04:05” Format string for the date. Only used for the text formatter. Refer to golang’s time package for information on how to create the format string https://golang.org/pkg/time/#Time.Format

Usage

Use gowl -h to see usage options

  1. Usage of gowl:
  2. -format string
  3. text formatter only. format for the output message. %L = log level. %D = Date. %M = Message (default "[%L] %D: %M")
  4. -formatter string
  5. format to output log messages as. [text, json] (default "text")
  6. -level string
  7. logging level. [debug, info, warn, error] (default "info")
  8. -port int
  9. port to listen on (default 8030)
  10. -route string
  11. route to listen for socket connections (default "/")
  12. -timeFormat string
  13. text formatter only. format string to output time logs. Format as defined here https://golang.org/pkg/time/#Time.Format (default "2006-01-02 15:04:05")