GithubHelp home page GithubHelp logo

logwatcher's Introduction

Log Watcher

Build Status

A Rust library to watch the log files.

Note: Tested only in Linux

Features:

  1. Automatically reloads log file when log rotated
  2. Calls callback function when new line to parse

Usage

First, add the following to your Cargo.toml

[dependencies]
logwatcher = "0.1"

Add to your code,

extern crate logwatcher;
use logwatcher::LogWatcher;

Register the logwatcher, pass a closure and watch it!

let mut log_watcher = LogWatcher::register("/var/log/check.log".to_string()).unwrap();

log_watcher.watch(&mut move |line: String| {
    println!("Line {}", line);
    LogWatcherAction::None
});

logwatcher's People

Contributors

aravindavk avatar romibuzi avatar 19h avatar denwav avatar noyez avatar

Stargazers

Marwane avatar Lyu.ZQ avatar CaNNaBaZZ avatar  avatar inc0gnit0 avatar  avatar loclv avatar HuaZhuangNan avatar Matthew Lloyd avatar Michael Lykke avatar James avatar  avatar Leonid Ryzhyk avatar Chuqiz avatar Erlang Parasu avatar Jonathan Dizdarevic avatar Antonio Perez Caballero avatar John Rees avatar Hank Bao avatar James McMurray avatar Ivan Dzhonev avatar  avatar Nikolay Kost avatar Szymon Mucha avatar dpods avatar Prashanth Pai avatar  avatar Thomas dugue avatar Maurizio Del Corno avatar Arne Bahlo avatar Joseph Kordish avatar

Watchers

 avatar James Cloos avatar Ivan Dzhonev avatar CaNNaBaZZ avatar

logwatcher's Issues

update crates.io version

Could you please update the version on crates.io?
The only version available there is the initial commit, missing the closure changes

Take a FnMut closure

Fn prevents the closure from mutating captured variables. Could we change it to FnMut to make the API easier to use in cases where we want to do this. This would be a braking change.

Printing from library

println!("reloading log file");

I think a print in a library should generally be avoided. If you think you're user might care about a log rotation, you should have it be an event that your watcher provides.

eg

enum Event {
    Line(String),
    LogRotation,
}

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.