1.2.1 • Published 4 months ago

sciter-logger v1.2.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

sciter logger

latest version downloads

This is a sciter.js logger that listens to the console output and redirects it to a file and/or any html element.

sciter logger screenshot

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 22 LTS) and its package manager npm.

add to your project

You can either add it to your project using npm or by copying the src directory.

using npm

  • install package npm install sciter-logger

copy source

  • add the src dir to your project

add to <script type="module">

// npm
import Logger from "node_modules/sciter-logger/src/logger.js";
// or source copy
import Logger from "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 the console 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();

iframes behave just like Windows 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
1.2.0

4 months ago

1.1.8

4 months ago

1.2.1

4 months ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago