Project

betterlog

0.0
A long-lived project that still receives updates
This library provides structure json logging for our rails projects
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
~> 1.12.0
>= 0

Runtime

>= 0
~> 1.0
~> 2.0
~> 1.3, >= 1.22.0
 Project Readme

betterlog

Description

Logging tools for betterplace structured logging in rails applications.

Configuration

Copy the example configuration in config/log.yml into your application to get you started. Then add this line to your Gemfile:

gem 'betterlog'

Usage

betterlog

Use it to tail local logfiles:

$ betterlog -f

or filter from stdin with

$ cat log/development.log | betterlog

Search for GET in the last 1000 rails log lines:

$ betterlog -F rails -n 1000 -s GET

Display the help for more options with betterlog -h.

betterlog_pusher

  • BETTERLOG_SERVER_URL is the URL log information is ultimately posted to in the form of https://user:password@appname-prd-log.betterops.de/log.

  • BETTERLOG_LINES, e. g. 1000, is the number of lines which are posted per every request to the above URL.

  • REDIS_URL the redis server URL for the server where Log information is stored before posted to the betterlog server.

    The rails application should be configured like this to store log information on this redis server:

    config.logger = Betterlog::Logger.new(Redis.new(url: ENV.fetch('REDIS_URL')))
    

betterlog_sink

This is a small wrapper around the kubectl logsā€¦ command, see kubectl help logs for the options.

To tail a log and prettify the output just call and pipe to the betterlog executable:

$ betterlog_sink --since=1m -f | betterlog

The sink always defaults to the production logfile, to switch the context to staging, prepend the command with the LOG_ENV env variable like so:

$ LOG_ENV=staging betterlog_sink -f | betterlog