Giter Club home page Giter Club logo

resitail's Introduction

Resitail

Version Apache 2.0 license

Stream residue server logs via various hooks

Quick start

  • npm install -g resitail
  • sudo resitail --config <config>

Notice the sudo, this is because all the files written by residue server will need sudo access as they may be owned by one user or another with limited permissions. Resitail needs to be able to read all of these log files.

Configuration

A configuration file looks like:

{
    "residue_config" : "<residue-config>",
    "hooks": [
    ... <see Connecting Hooks section below>
    ]
}

Creating Hook

Hook is essentially a JS module with following minimal requirements

  • A class with options constructor
  • A send function with data parameter.
  • Export this class

Once connected resitail will use this send function to send the logs. A most commonly used hook is resitail-f.

Example:

"use strict";

function sampleHook (options) {
    this.options = options;

    this.send = (data) => {
        console.log(data);
    }
}

module.exports = (options) => new sampleHook(options);

Data contains following properties:

Property Description
event Event name (i.e, resitail:line, resitail:err)
event_type Type of event (i.e, info, error)
line Contents of event (either log line or error details etc)
channel Type of channel (i.e, client or logger)
channel_name Name of channel (i.e, client_id or logger_id)
logger_id Logger ID if channel is client
client_id Client ID if channel is logger

Connecting Hook

Once hook is ready you can connect it by adding it to configuration.

{
    "name": "<hook name>",
    <path or package>
    "enabled": false,
    "config": {
        "channels" : {
            "to_client" : true,
            "to_logger" : true
        }
        ... more configs specific to hook
    }
}

A fully working hook configuration looks like:

From registry (notice package and version):

{
    "name": "resitail-f",
    "package": "resitail-f",
    "version": "latest"
    "enabled": true,
    "config": {
        "channels" : {
            "to_client" : true,
            "to_logger" : true
        }
        port: 3000
    }
}

This will install the package globally.

Local (notice path):

{
    "name": "resitail-f",
    "path": "../resitail-f",
    "enabled": true,
    "config": {
        "channels" : {
            "to_client" : true,
            "to_logger" : true
        }
        port: 3000
    }
}

Notes

License

Copyright 2017-present @abumq (Majid Q.)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

resitail's People

Contributors

abumq avatar dependabot[bot] avatar

Watchers

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