Giter Club home page Giter Club logo

clog's Introduction

clog

clog writes rotating log files, like multilog.

It reads stdin and writes to a rotating series of logs in a directory.

Rotation Scheme

The current log file is always called "current"; previous log files are renamed to roughly ISO 8601 format using the system time (hopefully UTC). A rotated file might be named:

a2013-03-09_19:50:33.048839

Deviations from strict ISO 8601 format are:

  • Files start with 'a' for easy glob matching (think: "archive") and to place them in earlier lexicographical order than "current"
  • An underscore is used to separate date from time instead of "T" for readability.
  • A period, then zero-padded microseconds follows the time.

This format keeps all files sorted in lexicographical order. ls LOG_DIR | tail will always give you the last 10 files, including current. Similarly, ls LOG_DIR/a* | head -n -5 | xargs rm will ensure only the most recent 5 archived logs are in LOG_DIR, which is a safe pruning scheme.

Once an a* file is created, is is never renamed or deleted unless you do so. This is a useful property for various processing schemes.

Termination

clog will exit and flush any buffered data into a log file when stdin is closed. If stdin does not end with a newline, clog will append a newline.

Installing

The build process requires GNU make and gcc. Some libc is needed, of course, but nothing else.

make && sudo make install

Usage

Using clog is very simple:

clog FILE_SIZE LOG_DIR

clog will make a decent effort to rotate the "current" file when it reaches FILE_SIZE bytes. FILE_SIZE can also contain a suffix (K, M, G, or T), for usage like:

/sbin/my_daemon | clog 100M /var/log/my_daemon

This would rotate files at 100 MB. You get the idea.

Portability

Thus far, clog has only been built on Linux. If you get it built somewhere else and have patches, send 'em along. It's pretty much just POSIX, so most things like Unix should work.

Differences from multilog

  • clog does not support dumping timestamps in your files.
  • clog also does not support removing old files.
  • clog has no pattern matching.

clog's People

Watchers

James Cloos avatar Aleph Archives 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.