LateLog - Simple storage-based Log Library

Simple library to log to the storage, granting the possibility of viewing the log after the URL changes

当前为 2023-03-02 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/461057/1156386/LateLog%20-%20Simple%20storage-based%20Log%20Library.js

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
satology
版本
0.2
创建于
2023-03-02
更新于
2023-03-02
大小
5.1 KB
许可证
暂无

LateLog

Simple library created to store log messages, basic errors and JSON while using a crawler.

It adds a View log button to the script menu in TM that prints the stored messages to the console.

Basic usage

  1. Import the library using @require as stated above the script description

  2. Grant the following permissions to your script:

// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_registerMenuCommand

and then:


// Create a LateLog instance:
let late = new LateLog();

// Then just log using LateLog:
late.log('This will be stored');

Extended Example

You have access to 5 methods, so you can later view the messages in a similar way as when using console.log


late.log('Text saved as log');
late.info(`Date: ${new Date()}, as info`);
late.debug('Text saved as debug');
late.warn('Text saved as warning');
late.error('Text saved as error');

// Log a JSON stringifyable object
late.debug({ name: 'object log example' })

// Log an error using any level
try {
    let failme = something.that.fails;
} catch (err) {
    late.error(err);
    late.warn(err);
    late.info(err);
}

Customization

You can override some basic options when instantiating


let late = new LateLog({
    level: 5, // max level to store (from 1-log to 5-error)
    maxLines: 200, // max number of lines to store
    addTimestamp: true, // adds YY-MM-DD hh:mm:ss to the log
    printWhileLogging: false // prints new saved messages to console when storing
});