Giter VIP home page Giter VIP logo

logtail_crystal's Introduction

logtail_crystal

An implementation of the logtail command written in Crystal Lang

Behavior:

  • Checks the byte size of a file and compares it to the offset. If the byte size has increased it prints out any new lines.
  • If the inode has changed it starts from the beginning
  • If the file size is smaller than the offset, it starts from the beginning

To build on Ubuntu 22:

  • Make sure you have Crystal 1.8.2 installed
  • Clone the repo: git clone https://github.com/weirdbricks/logtail_crystal.git
  • Build: crystal build --static --release --no-debug logtail.cr
  • Strip: strip logtail
  • Run: ./logtail

Optionally also move to /usr/local/bin

crystal build --static --release --no-debug logtail.cr
strip logtail
mv ./logtail /usr/local/bin/

Usage instructions:

This command requires 1 argument which is the logfile you want to view. Subsequent runs of the command against the same logfile will only display any new lines.

Optionally you can provide a second argument which is the offset file that you want to use. If you do not provide an offset filename, one will be created for you under /tmp/#{filename}.offset.

Example 1 - Getting new lines from /var/log/syslog

./logtail /var/log/syslog

Example 2 - Getting new lines from /var/log/syslog and creating an offset filename at /dev/shm/buhahaha

./logtail /var/log/syslog /dev/shm/buhahaha

Example 3 - Getting new lines from /var/log/syslog without diagnostics:

./logtail /var/log/syslog /dev/shm/buhahaha 2>/dev/null

logtail_crystal's People

Contributors

weirdbricks avatar

Watchers

 avatar  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.