Giter VIP home page Giter VIP logo

tztail's Introduction

tztail

Build Status

tztail (TimeZoneTAIL) allows you to view logs in the timezone you want. Its tail with timezone.

Install

brew tap thecasualcoder/stable
brew install tztail

Usage

$ tztail --help
tztail 1.0.0
tztail (TimeZoneTAIL) allows you to view logs in the timezone you want

USAGE:
    tztail [FILE]

OPTIONS:
    -t, --timezone <TIMEZONE>    Sets the timezone in which output should be printed. (Default: local timezone)
    -f, --format <FORMAT>        Custom format for parsing dates. (Default: autodetected patterns)
    -h, --help                   Prints help information
    -V, --version                Prints version information

ARGS:
    <FILE>    File to tail. STDIN by default

Features

  • Supports few standard formats with which auto detection is done when parsing logs.
  • Supports specifying custom format for parsing in case it is a non-standard format. See here for formats.
  • Autodetect source timezone if present in logs. Example (2014-11-28T12:00:09+0100 is CET)
  • Output logs to local timezone by default

Demo

demo

Autodetectable formats

Most used autodetectable formats

Name Example
RFC2822 Fri, 28 Nov 2014 12:00:09 +0000
RFC3339 2014-11-28T12:00:09+0000
Nginx Log format 04/Nov/2018:12:13:49

Usecase

This tool can be used to convert timestamps in a log to any desired timezone while tailing logs. Eg. In case your logs are in UTC and you want to view it in a different timezone say. Asia/Kolkata (IST), pipe the logs through tztail.

## Example usage
$ cat somelog # A log in UTC
2018-11-03 19:47:20.279044 I mvcc: finished scheduled compaction at 104794 (took 748.443µs)
2018-11-03 19:52:20.282913 I mvcc: store.index: compact 105127

$ cat somelog | tztail --timezone Asia/Kolkata # Timestamps converted to IST
2018-11-04 01:17:20.279044 I mvcc: finished scheduled compaction at 104794 (took 748.443µs)
2018-11-04 01:22:20.282913 I mvcc: store.index: compact 105127

It allows to specify a custom format as well.

## Example usage
$ cat somelog # A log in non-standard format
2018-11-03 20:07:20 mvcc: store.index: compact 106120
2018-11-03 20:07:20 mvcc: finished scheduled compaction at 106120 (took 933.25µs)

$ cat somelog | tztail -t Asia/Kolkata -f "%Y-%m-%d %H:%M:%S"
2018-11-04 01:37:20 mvcc: store.index: compact 106120
2018-11-04 01:37:20 mvcc: finished scheduled compaction at 106120 (took 933.25µs)

Building from source

Checkout the code and build locally

$ git clone https://github.com/thecasualcoder/tztail
$ cd tztail

# To build binary locally
$ cargo build --release

# To install binary locally in Cargo bin path
$ cargo install

# To run tests
$ cargo test

Roadmap

  • Support all standard datetime formats.
  • Allow custom datetime format.
  • Add option to read from file.
  • Auto-detect source timezone if possible.
  • Allow specifying source timezone explicitely.
  • Support GCP/AWS cloud logging formats.
  • Performance optimizations
  • Add support to pass time-window which would only show the logs in that time period

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.