Skip to content

8ctopus/sciter-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Feb 25, 2025
2405c72 · Feb 25, 2025
Jan 11, 2022
Feb 25, 2025
Jan 11, 2022
Jan 24, 2022
Feb 11, 2025
Feb 20, 2025
Dec 26, 2022
Dec 28, 2022
Feb 25, 2025
Feb 25, 2025
Jul 16, 2021
Aug 4, 2021
Dec 28, 2022

Repository files navigation

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