remote-logging
v1.4.4
Published
A tool to enable remote logging for AnaLogger
Downloads
41
Maintainers
Readme
Remote-Logging is a remote log viewer.
Installation
# Install modules globally
npm install remote-logging -g
or
# Run module with no installation step from a temporary directory
npx --yes remote-logging@lates
On Linux, you will need to open the port for the devices on your network can access the console.
Centos:
sudo firewall-cmd --add-port=12000/tcp --permanent
sudo firewall-cmd reload
Other distributions:
sudo iptables -A INPUT -p tcp --dport 12000 -j ACCEPT
sudo systemctl restart iptables
Refer to your distro for a more precise set-up.
On windows, it may ask to allow access to the port (12000 by default)
Usage
With Remote Logging, you can automatically console.log
your data to the viewer.
From a Shell
$> remote-logging [--port 12000]
Demo
Send logs from a logger
To send logs from a logging system to remote-logging, you must send a POST request with the following format:
[
[{"lid": 123888, "color": "blue"}, "My message 1"],
[{"lid": 123939, "color": "blue"}, "My message 2"],
[{"lid": 123959, "color": "blue"}, "My message 3"],
]
The lid is a random number
$> curl --request POST 'http://your-server-ip:12000/analogger' --data-raw '[{"lid": 123888}, "My message"]'
Example with Postman
Send logs from a browser to Remote Logging
To send logs from the browser, you can use fetch
and adapt the formatting above
fetch("http://localhost:12000/analogger", {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(/** Your formatted data **/),
redirect: 'follow'
})
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Send logs from AnaLogger
You can send log from AnaLogger by passing true to the logToRemote option.
const {anaLogger} = require("analogger");
anaLogger.setOptions({logToRemote: true});
Go to the AnaLogger page for more options:
https://www.npmjs.com/package/analogger
Tests
Use Remote-Logging as a Mocha Test reporter
Mocha is a JavaScript test framework: https://www.npmjs.com/package/mocha
Description of how to have Remote-Logging working as an automated test viewer
- Install Remote-Logging
$> npm install remote-logging
- Launch Remote-Logging
# Port by default
$> remote-logging --port 8221
- Pass the path of the reporter to Mocha
mocha --reporter=./node_modules/remote-logging/reporter.cjs
Reporter Options
To pass options to the reporter, use environment variables:
| Name | Description | Default | |-------------------------------------------|---------------------------------------------------|---------------------------------| | ANALOGGER_TEST_PORT | Port you wish to set the remote-logging server to | 8221 | | ANALOGGER_LOG_FILE | To add log into a file | | | ANALOGGER_LOG_TO_REMOTE_URL ** | To change the remote url for logging | http://localhost:8221/analogger | | ANALOGGER_LOG_TO_REMOTE_BINARY_URL ** | To change the address for screenshots | http://localhost:8221/uploaded |
** Set these if you have updated your AnaLogger configuration to point to custom URLs
Example
Linux:
export ANALOGGER_TEST_PORT=12000
export ANALOGGER_LOG_FILE=reporter.log
mocha --reporter=./node_modules/remote-logging/reporter.cjs
Windows (Powershell)
$env:ANALOGGER_TEST_PORT = 12000
$env:ANALOGGER_LOG_FILE = "reporter.log"
mocha --reporter=./node_modules/remote-logging/reporter.cjs
Uninstall Remote-logging
$> npm remove remote-logging -g
Changelog
current:
- Fix Js error in reporter
1.4.2:
- Display Remote-Logging version in the console
1.4.0:
- Set up Remote Logging as a Mocha reporter
- Open a new window with the application icon
- Review screenshot viewer for takeScreenshot plugin
1.3.1:
- Fix updater
1.2.0:
- Release standard input in CLI after launching Remote-Logging
1.1.2:
- Remove close button from splash screen progress bar
- Display port in the notification
- Show tray notification when the application starts
- Review the exit button from the tray icon
- Fix missing screenshots
- Fix messages not being logged
- Fix bug with failing ips
- Select listening port with --port option
- Review layout
- Fix application launcher