sciter-logger
v1.1.7
Published
This is a [sciter.js](https://sciter.com/) logger that listens to the console output and redirects it to a file and/or any html element.
Downloads
4
Readme
sciter logger
This is a sciter.js logger that listens to the console output and redirects it to a file and/or any html element.
This work was made possible thanks to https://2ality.com/2015/10/intercepting-method-calls.html.
demo
- git clone the repository
- install packages
npm install
- install latest sciter sdk
npm run install-sdk
- start the demo
npm run scapp
demo requirements
- A recent version of Node.js
node
(tested with 16 LTS) and its package managernpm
.- On Windows download and run the installer
- On Linux check the installation guide
add to your project
using npm
- install package
npm install sciter-logger
copy source
add the
src
dir to your projectadd to
<script type="module">
import Logger from "node_modules/sciter-logger/src/logger.js";
// initialize logger
Logger.init({
url: __DIR__ + "%DATE%.log",
clear: true,
});
// attach logger to console
Logger.attach();
// capture unhandled exceptions
Logger.capture();
// log
console.log("new logger test");
enhanced console
Console is enhanced with new methods
console.debug("test debug");
console.exception("test exception");
console.note("test note");
console.line();
objects can be logged
console.debug({
a: 1,
b: {
alpha: "test",
beta: "yet another test"
},
c: 3,
});
redirect console output
Console output can be redirected to a plaintext element
Logger.plaintext(document.$("plaintext"));
Output can be colored if you include the stylesheet
<style src="node_modules/sciter-logger/src/logger.css" />
subscribe to logger
Logger.subscribe(function(level, message) {
});
multiple windows and iframes
- as each
Window
has its own console, you will need to use theconsole
object from the parent window:
import Logger from "src/logger.js";
// get console from parent
Logger.setConsole();
- unhandled exceptions must also be captured in every new
Window
.
import Logger from "src/logger.js";
// capture unhandled exceptions
Logger.capture();
iframe
s behave just like Window
s in that aspect.
ideas
- open log file only once? would require non-exclusive rights to the file
- spawn a separate logging window
- add icons for each channel