Code Monkey home page Code Monkey logo

logformat's Introduction

Overview

Logformat is an IRC bot that logs into a database, and a web frontend to show these logs.

History

Logformat is the reincarnation of an earlier, ehrm, system that transformed log files from my irssi setup into something resembling HTML. Along the way, it employed horrible spaghetti code and chains of regular expressions.

Components

All executable components live in bin. They share models and helpers from lib, including the basic configuration logic and database access.

bot.rb

The IRC bot. It will connect to one IRC network, join all channels in the database that have the join flag set, listen for and record all messages.

web.rb

A Sinatra web app that displays the logs, one day at a time, for all channels. It employs a simple ACL scheme to allow restricted access to certain channels.

import.rb

A script to read, parse and store the Irssi logfiles. It tries to avoid duplicates, but since the bot's recorded messages have second precision but the logfiles only minutes, importing logs from times when the bot was listening will lead to duplication.

console.rb

A pry REPL with all libraries preloaded. Currently, this is the only admin interface.

dump.rb

A simplistic script to dump the whole database in plain text format. Note that the format is currently not supported by the parser employed by import.rb.

Configuration

Runtime configuration is performed through environment variables. These are:

  • DB: URI for database access, e.g. postgres://user:pass@localhost/database. Default: sqlite://local.db (i.e. the local.db file in the current directory).
  • PORT: listen port for the web component. The web component will by default only listen on the local interface, use a web server like nginx to proxy. See below for a configuration example.
  • BIND: interface to bind to. Set to 0.0.0.0 to bind to all interfaces. Default: 127.0.0.1
  • SERVER: IRC server to connect to. Default: irc.freenode.net
  • NICK: Nickname to connect with. Default: logformat

nginx configuration example

Proxy to the web interface using proxy_pass, and pass the host header:

location / {
  proxy_pass http://localhost:8080;
  proxy_set_header Host $host;
}

A note about database support

Currently, the default database is SQLite 3. It is also used for tests (as an in-memory databse). However, it is recommended to use Postgres for real use-cases, it is much faster and more stable. I have encountered severe concurrency problems with all but Postgres during multithreaded imports.

It is very likely that sooner or later Postgres will be the only supported database backend.

Access Control Lists

Web access to a channel is controlled by a simple list of yes/no rules (the Permission model). The default is to allow access. Users are authenticated using HTTP Basic authentication. Unauthenticated users are represented by the special "anonymous" user.

To disable anonymous access to a channel, start the console and run

channel = Channel.find(:name => '#mychannel')
channel.deny_anonymous!

To create a user and allow access to the channel for them,

user = User.create(:name => 'joe', :password => 'password', :password_confirmation => 'password')
channel.allow!(user)

Docker

Pre-built Docker images are available. When running, you most likely want to set the DB environment variable. Commands are run in the correct bundler context. The default command is web.rb.

logformat's People

Contributors

erlehmann avatar matthiasr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

logformat's Issues

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.