Skip to content

[preview] A simple as-it-is message logger powered by socket.io

License

Notifications You must be signed in to change notification settings

unknownmoon/tool-socketio-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tool-socketio-logger

A simple as-it-is message logger powered by socket.io

How to use

Get the server

NPM install from GitHub globally

npm i -g git+https://[email protected]/unknownmoon/tool-socketio-logger.git
  1. run tool-socketio-logger to start with default color mode (bright);
  2. run tool-socketio-logger --color dark to start with color mode dark, if you're using black background in your terminal
  3. use --port or -p to specify the port your should like to use.

Using source code

  1. check out the project
  2. run npm i to initialise the project
  3. run npm start to start with default color mode (bright)
  4. run npm run start-dark to start with color mode dark, if you're using black background in your terminal

Inject script to your HTML

The API is /api/v0/socket-inject/, while the query func is the global function to communicate with the logger. In the example below, __debug and __log are registered to the logger, with differently coloured outputs.

<script src="http://localhost:9528/api/v0/socket-inject?func=__debug&func=__log"></script>
<scirpt>
    // how to use the client logging functions
    __debug(location);
    __log(location);
</scirpt>

Newly add from in query, for providing an id other than the random socket id. (Note that socket id will be used if from is ommitted.)

<script src="http://localhost:9528/api/v0/socket-inject?func=__debug&func=__log&from=alice"></script>
<scirpt>
    // how to use the client logging functions
    __debug(location);
    __log(location);
</scirpt>

About

[preview] A simple as-it-is message logger powered by socket.io

Resources

License

Stars

Watchers

Forks

Packages

No packages published