Skip to content

Simple and Lightweight real-time log debugger via Websocket with Nodejs, SocketIO and Restful API to feed log (PHP, Python...)

Notifications You must be signed in to change notification settings

voduytuan/Realtime-Logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Realtime-Logger

Simple and Lightweight real-time log debugger via Websocket with Nodejs, SocketIO and Restful API to feed log (PHP, Python...)

Log Monitor

Introduction

Use this small library to create real-time log for your application. There are 3 parts in this system:

  • Socket Server: Run WebSocker server on port 8080, will transmit log from your code (Log Pusher) to connected Log Monitors
  • Log Monitor: UI to show all logs of connected socket.
  • Log Pusher: Your code, will request POST method to socket server to push log to Log monitor. This repositofy come with PHP example Pusher.

Installation

Required: Nodejs, port 8080 available on server (you can change in server.js sourcecode and client javascript) If not using localhost, you can change rooturl at socketserver/server.js, socketclient/index.html, pusher/WebSocketDebugger.php

Start socket server with this: > node socketserver/server.js

Open Log monitor in browser with URL: http://localhost/realtimelogger/socketclient/index.html (i assume that you put all directory in realtimelogger in www)

Test push with pusher/example.php

Persistent

For the simplicity, database is not used here in this system. All data/packet send via web socket connections and there is no persistent storage in this system. If you refresh your Log Monitor page, all logs will be cleared.

Security

There is no security layer here. Every Log Monitor will be assigned an User ID (default: 1), you can change in UI of Log Monitor. If Log Pusher do not specify user id in POST data, all connected Log monitors will be received this Log.

Pushing with Restful

You can send your log to Log Monitor with Restful POST request. Data send in Json format and in Request Body. Request json format:

{
  uid: Integer,
  emit: "log_receive",
  time: String,
  type: String (debug, error, warning, info,...),
  detail: String
}

PHP Usage

This repository comes with php example. Just include file "WebSocketDebugger.php", create object instance and call Push() method to push debug information to socket server. Example:

...

include('WebSocketDebugger.php');

$userId = 123;
$socketUrl = 'http://localhost:8080/';
$myDbg = new WebSocketDebugger($socketUrl);
$myDbg->push('My Log here', $userId, 'info');

Enhancement & Customization

You can change the format of message in socketclient/assets and parsing more data as you want.

About

Simple and Lightweight real-time log debugger via Websocket with Nodejs, SocketIO and Restful API to feed log (PHP, Python...)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published