Code Monkey home page Code Monkey logo

regorxxx / console-smp Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 44 KB

A helper script for Spider Monkey Panel which allows to permanently save console logs to a file using the existing method (console.log).

Home Page: https://regorxxx.github.io/foobar2000-Framework-SMP.github.io/scripts/console-smp/

License: GNU Affero General Public License v3.0

JavaScript 100.00%
foobar2000 foobar2000-component foobar2000-smp-script spidermonkey-engine foobar2000-smp-framework

console-smp's Introduction

Console-SMP

version CodeFactor CodacyBadge GitHub
A helper script for Spider Monkey Panel and foobar2000 which allows to permanently save console logs to a file using the existing method (console.log).

The problem with current Foobar2000's console

Default UI allows to open the console log into a panel and save its content to a file, but the option is reset on every start-up... thus defeating the idea of logging to a file. Since file logging may be useful on servers, specially when using headless installation and interacting with SMP scripts (to check response), this utility is offered as alternative.

Features

  • Saves any message sent to the console on a text file (path configurable).
  • Saving is not reset on every start-up (contrary to Foobar2000's native console).
  • File is only reset when certain file size is reached (configurable).
  • Works 'as is' without any modification on existing scripts, just include it and done.
  • Converts sets and maps to arrays before logging.
  • Converts standard objects and functions to strings before logging.
  • Writing frequency to physical file can be adjusted.

Usage

Just include the helper file:

include('helpers\\helpers_xxx_console.js');

Since the original method has been wrapped, it will work without further modifications on an existing script:

console.log('This is output to log file at foobar profile folder and to console on UI.');

A method has been created to only send the message to the the UI console:

// This simply replicates the original method
console.logUI('This is output only to console on UI. New method.');

Another to send the message to both the console (+ file) and a popup:

// New lines '\n' are split into new entries before sending them to the console
console.popup('This is output to log file at foobar profile folder, console on UI and a popup.\nNew method.', 'My popup');

Capture

As a bonus, the profiler has also been wrapped:

// FbProfiler follows the same logic
const test = new FbProfiler('test');
// Do something
for (let i = 0; i < 999999; i++) {Object.getOwnPropertyNames({});}
// Outputs bare time in ms like "143"
console.log(test.Time);
 // Outputs "test". In standard SMP it would be undefined
console.log(test.Name);
// Outputs component name/version/assigned name like "Spider Monkey Panel v1.0.0: profiler (test): 166 ms"
// To console and file
test.Print();
// Only to console
test.PrintUI();

image

There is an usage example on the 'examples' folder.

Other implementations

  1. Playlist-Tools-SMP: Different tools for foobar2000.
  2. Playlist-Manager-SMP: A playlist manager for foobar2000.
  3. Any of my other scripts....

Installation

Since the addon only requires 1 file, i.e. the main helper, you can simply include it along any other script where you will use it.

carbon(6)

console-smp's People

Contributors

regorxxx avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.