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

persisted-logs

v2.11.20240912

Published

(BetterLogs) An always persisted logging library.

Downloads

1,155

Readme

persisted-logs - A Persistent Logger

A lightweight, efficient logging system designed for both server environments and command-line interface (CLI) applications. Persistent Logger outputs logs to the console and stores them in a SQLite database for easy retrieval and management. Ideal for developers who value long-term data persistence and the flexibility of SQL for data manipulation.

Features

  • Console & SQLite Logging: Seamlessly logs messages to both the console and a SQLite database.
  • Searchable Logs: Leverage SQL to easily search and filter log data.
  • Data Persistence: Designed for long-term data storage, making it easier to track historical log data.
  • Configurable Data Retention: (Soon) Includes a mechanism to periodically clean up old data, with customizable settings to manage data retention according to your needs.

Getting Started

Targets

Generally node.js applications. Not meant for use in the browser since browsers are client side.

Installation

Install persisted-logs via npm:

npm install persisted-logs
import BetterLog from "persisted-logs";

(async function() {
  const bl = new BetterLog({ dbName:"unit-test-2.db",silent: false });
  const {debug, info, warn, error, hush, unhush, hushNext} = bl; // Destructure the methods for easier access.
  
  try {
    await bl.info(['demo', 'test', 'alina'], `This is an info message. ${Date.now()}`);

    await bl.debug(['demo', 'debug','test', 'Alina'], 'This is a debug message');
    await bl.error(['demo', 'test', 'error', ' ALL_TAGS_ARE_NORMALIZED_TO_lowercase'], `This is an error message. it gets ${Date.now()} highlighted as an error`);

    await bl.warn(['demo', 'test', 'warn', 'spaces are ok'], `This is a warning message. it gets highlighted as a warning ${Date.now()}`);
  } catch (er) {
    const _null = "[null]";
    console.error(er?.toString() || _null);
    await bl.error([], er?.toString() || _null);
  }

  try {
    bl.hush();
    await bl.info(['demo', 'hush test', 'hush-test'], `This is the hush demo. When you hush, it silences all output to the console. If you call hushNext(), it will only silence the next log message.`);
    await bl.debug(['demo', 'hush test', 'hush-test'], 'The hush method will continue across all log levels until you call unhush().');
    await bl.error(['demo', 'hush test', 'hush-test'], 'This includes error messages. Again, all of these still go to the persistent log.');
    bl.unhush();
    await bl.info(['demo', 'hush test', 'hush-test', 'unhush'], `Since Unhush has been called, this will go to the console.`);
    bl.hushNext();
    await bl.warn(['demo', 'hush test', 'hush-test', 'hushNext'], `This will be hushed since hushNext() was called.`);
    await bl.info(['demo', 'hush test', 'hush-test', 'hushNext'], `This will not be hushed though. It will go to the console.`);
  } catch (er) {
    const _null = "[null]";
    console.error(er?.toString() || _null);
    await bl.error([], er?.toString() || _null);
  }
})();

SQL - The Real Power™

Consider the power of SQL in searching and filtering logs. For example, to search for logs with the tag "demo". Consider the benefit of using filters to chase down production bugs and such. Use tags to associate session Ids, user ids or methods to logs.

select t.tag, al.log_message, al.created_on, t.id, al.id
from app_log al
join log_tags lt on lt.log_id=al.id
join tags t on lt.tag_id=t.id
where t.tag='demo'
order by t.created_on desc, al.id desc;

Please see the wiki for more information on how to use this package.

persisted-logs/wiki

https://github.com/TheOpenSourceU/persisted-logs/wiki

License

This project is open source and available under the MIT License.

Acknowledgments

Made with ❤️ by Frank Villasenor (https://www.theOpenSourceU.org) for the heck of it. Check out our other projects, like AI Poems at https://poems.theOpenSourceU.org/.
Support

For support, please open an issue in the GitHub repository or contact the maintainers directly through https://www.theOpenSourceU.org.