solidusjs / solidus

A simple server that generates pages from JSON and Templates
MIT License
28 stars 7 forks source link

Send logs to a web socket with socket.io. #113

Closed joanniclaborde closed 10 years ago

joanniclaborde commented 10 years ago

A log server can be started by specifying the log_server_port option. A log_server_level can also be set, else log_level will be used, else 2. The web socket library used is socket.io, the event name is log and the message is an object with two properties: level and message. Example usage:

<script src="socket.io.js"></script>
<script>
  var socket = io('http://localhost:8089');
  socket.on('connect', function(){
    console.log('connected')
    socket.on('log', function(data){console.log(data)});
    socket.on('disconnect', function(){console.log('disconnected')});
  });
</script>

Once this change is merged, I'll need to modify vagrant-solidus and solidus-site-template to automatically open a port for the log server in dev.

joanniclaborde commented 10 years ago

Note that I considered switching to a better logger library like winston, but it'll have to wait for now.

joanniclaborde commented 10 years ago

TODO: add command line arguments to solidus/bin/solidus

localjo commented 10 years ago

I think this line should have this.options.log_server_port instead of this.log_server_port. Right now it prints the server port as undefined.