d08ble / livelogging

LiveLogging for LiveComment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LiveLogging for LiveComment

API

log(path, message)
replace(path, message)
erase(path)

Usage NodeJS

var LiveLogging = require('livelogging')

var options = {
    datafile: '1.log',
    logToConsole: true,
    server: true,
    port: 7089
}

// A. Run server

LiveLogging.server(options)

// B. Open file, no server

LiveLogging.open(options.datafile)

// LiveLog message to path

LiveLogging.log('path', 'message')
LiveLogging.replace('path', 'message')
LiveLogging.erase('path')

Usage Browser

    ...
    <script src="livelogging-1.0.js"></script>
    ...
    <script>
        // connect
        var livelogging_port = 7089
        var url = 'ws://localhost:'+livelogging_port
        LiveLogging.connect(url, function () {
            // connected
            LiveLogging.log('path', 'message')
            LiveLogging.replace('path', 'message')
            LiveLogging.erase('path')
            ...
        })
    <script>

Run Demo Sever

cd bin
./livelogging logs/1.log --server --commentPrefix="@'_'@"

Log file sample

See like that logs/1.log

@'_'@ -*-LiveLogging-*-[
@'_'@ LiveLogging[
@'_'@ Status[
|2016-03-05 16:41:09.822| server.started
@'_'@ Status]
@'_'@ Config[
|2016-03-05 16:41:09.826| {
  "port": 7089,
  "commentPrefix": "@'_'@",
  "datafile": "logs/1.log",
  "logToConsole": false,
  "queueMessagesMax": 50,
  "flushMessagesCount": 25,
  "serverFlushTimeout": 500,
  "dataFileFlushTimeout": 100,
  "dataFileFlushQueueMessagesMax": 100000
}
@'_'@ Config]
@'_'@ LiveLogging]
@'_'@ -*-LiveLogging-*-]

Open test page

open public/index.html

Wait some seconds & refresh log file

Final

Configure LiveComment and see LiveLogging process in browser

License

MIT

About

LiveLogging for LiveComment

License:MIT License


Languages

Language:JavaScript 88.2%Language:HTML 11.8%