Code Monkey home page Code Monkey logo

live_logs's Introduction

#LiveLogs

##What is live logs ?

It's a Rails Engine that displays app logs in your browser, live! And .. It looks like this:

Screen shot

##Why it was created ?

Because a client asked me to perform the following 'Test-Task'

Develop a simple RoR application that use backbone and marionette.js on the client side. The application scans any log file (development.log, syslog, ..) for updates. When a new line appears on the log file it is passed to the client and is rendered in one of two sections. Choose an arbitrary filtering rule of the new lines...

##Demo ?

git clone '[email protected]:proxygear/live_logs.git'
cd live_logs
bundle
cd spec/dummy
passenger start
open http://localhost:3000

##Why passenger ?

Actually you can use whatever service you like that handle localy multiple requests simultenously. Streaming request does not stop unless client cut the connection. So if you use a 'single request at a time' solution, after starting streaming logs, your app will be stucked. But, you can steal $> echo 'test' > logs/my.log to emulate traffic.

  • Webrick is one at a time
  • Puma can be tuned to allow simultaneous requests
  • Passenger does the job
  • For the others, RFDocs...

##How to use it ?

In your Gemfile add:

gem 'live_logs', git: '[email protected]:proxygear/live_logs.git'

In your routes.rbadd:

mount LiveLogs::Engine => "/whatver_path"

Then bundle your app, run your server and visit '/whatver_path'

##Does it works on Heroku ?

Nop or not as expected. Heroku cut open connection after N seconds as far as I know. Even if SourceEvent restart automagicaly broken connection, the streaming will restart at file logs end minus ~ 25 lines. So you'll see passing at each reconnection 25 lines already seen. This may be fixed with a bunch of extra work, that you may do it yourself.

##How does it works ?

It uses:

  • Ruby 1.9+
  • file-tail gem to keep reading log files
  • Rails ActionController::Live to stream the logs
  • Javascript EventSource to get a persistant connection
  • MarionetteJS (before v2) in addition of Backbone (before v1) for the interactivity
  • And zurb foundation because ... it's my default CSS Framework

##Needs, questions or feedbacks ?

Feel free to create an issue and/or to contact me.

##Dependencies

  • Rails 4+

##LICENSE

This project rocks and uses MIT-LICENSE.

live_logs's People

Contributors

aussidavid avatar original-brownbear avatar proxygear 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.