Coder Social home page Coder Social logo

scotty's Introduction

beam me up, scotty!

scotty gopher :)

Why scotty?

Often times when you develop an application on your local system it's not enough to run a single application but maybe many different ones. The idea behind scotty originated from the resulting pain of having many terminal windows printing logs and stitching together the logs you need in order to understand the bug you're searching for..tedious

With scotty you can multiplex your application logs into one consolidated terminal window apply filterss on specific streams and format structred (JSON format) logs. In the future the secondary goal of scotty is it to allow you to query/aggregate your logs.

Installation guide

Homebrew

brew tap KonstantinGasser/tap
brew install scotty beam

From source

go install github.com/KonstantinGasser/[email protected]
go install github.com/KonstantinGasser/[email protected]

How it works?

Somehow your logs need to be send or say beamed to scotty. This is why scotty comes with a helper command called beam. Beam pushes everything it reads from stdin to scotty. Just be aware that things printed to stderr won't work..but we can redirect stderr to stdout using 2>&1.

How to use it?

...from stdout

cat uss_enterprise_engine.log | beam -d engine-service

This above command cats the uss_enterprise_engine.log to stdout which is then piped to the stdin of beam. Note the beam's first argument will be the name referenced in scotty.

...from stderr

go run -race cmd/my/application.go 2>&1 | beam my-application

Here application.go produces logs printed to stderr this is why we need to add 2>&1 to redirect the output to stdout. The pipe to beam stays unchanged.

Format a log line

Especially when logs are structured we humans have it hard to read the unformatted JSON. Hit the : key and type the line number of the log you want to format.

Hint: once the log line is displayed use the arrow keys for up and down (or j, k) to parse the previous or next line

Filter on streams

When you need to only look at certain logs form a subset of streams your can apply a filter. Hit ctrl+f followed by a comma separated list of the streams you want to focus on. While the filter is applied you can browse through the subset of logs as usual with : <index>. To remove set filters hit the q key

Options with beam

Currently beam only allows to pipe data through unix sockets..however beam as well as scotty are build such that both will support piping data via a tcp:ip connection which enables you to beam logs from for example docker instances to scotty :)

In case it fails, it fails!

Since scotty is still under active development panics within the program might happen. In such case you might need to delete the create unix socket before restarting scotty. The default path for the socket scotty is using is /tmp/scotty.sock. This does not apply if you used tcp:ip

scotty's People

Contributors

konstantingasser avatar petryeric avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.