npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wappler-advanced-logger

v1.2.0

Published

This extension for Wappler provides advanced logging functionality using the [Pino](https://github.com/pinojs/pino) library, [Logtail](https://logtail.com) for log aggregation, and [Sentry](https://sentry.io) for error tracking. It allows you to log messa

Downloads

326

Readme

Advanced Logger Extension for Wappler

This extension for Wappler provides advanced logging functionality using the Pino library, Logtail for log aggregation, and Sentry for error tracking. It allows you to log messages with various log levels, supports multiple transport options such as console, file, and Logtail, and provides log redaction capabilities.

Features

  • Customizable log levels
  • Pretty printing for console output
  • Integration with Logtail and Sentry
  • Log redaction support for sensitive data
  • Log file management (automatic creation and removal)
  • Flexible transport configuration

Installation

Add the following dependencies to your package.json:

npm install pino

Transports and Required NPM Packages

The Advanced Logger Extension supports multiple transport options such as console, file, Logtail, and Sentry. Depending on which transports you want to use, you need to install the corresponding NPM packages and configure the relevant environment variables.

Pretty Log

Add the following dependencies to your package.json:

npm install pino-pretty

Configure the following environment variable:

  • PRETTY_LOG: Set to 'enabled' for pretty-printed console output.

File

No additional NPM packages are required for file logging.

Configure the following environment variables:

  • LOG_FILE_PATH: Set the path to store log files.
  • WRITE_LOG_MIN_LENGTH: Set the minimum log message length to write to a file.

Logtail

To use Logtail for log aggregation, install the following NPM package:

npm install @logtail/pino

Configure the following environment variable:

  • LOGTAIL_TOKEN: Set the Logtail source token for log aggregation.

Sentry

To use Sentry for error tracking, install the following NPM package:

npm install @sentry/node,

Configure the following environment variable:

  • SENTRY_DSN: Set the Sentry DSN for error tracking.

Express HTTP Logging

To enable Express HTTP logging with the Advanced Logger Extension, you'll need to install the pino-http package. Add the following dependency to your package.json:

npm install pino-http

After installing the package, you can use it as middleware in your Express application to enable HTTP logging.

Configuration

The extension uses environment variables to configure various settings. These variables can be set in your .env file:

  • LOG_LEVEL: Set the log level (e.g., trace, debug, info, warn, error, fatal).
  • LOG_ENVIRONMENT: Set the log environment (e.g., production, development, etc.).

Redaction

To redact sensitive data from your logs, you can customize the redaction keys in the redaction-keys.js file. The keys correspond to the properties in the log object that you want to redact.

For example, to redact the user_id and secret_key in the details object, your redaction-keys.js file should look like this:

const redactionKeys = [
    'details.user_id',
    'details.secret_key',
];

module.exports = { redactionKeys };

Extension UI Actions

The extension provides two UI actions that can be used in Wappler: Advanced Log and Clean Old Logs.

Advanced Log

This action logs a message with the specified log level and details.

Clean Old Logs

This action cleans old log files, removing files older than the specified number of days. Add this action to a node scheduler if you have file logging enabled and scheduled it for the desired interval. The action will scan the log directory specified in the ENV LOG_FILE_PATH.

Extension Developers

To integrate the Advanced Logger extension into your project, follow these examples:

Sync Logging

const { logMessage } = require("./advanced-logger");

logMessageSync({
message: "Example log message",
log_level: "info",
details: {
    key1: "value1",
    key2: "value2"
    }
});

Async Logging

const { logMessage } = require("./advanced-logger");

await logMessage({
    message: `Fetching vulnerabilities took ${fetchTime - startTime} ms`,
    log_level: "debug",
    details: {
        user: "[email protected]",
        request_id: "12345"
    }
});