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

orwellian

v1.0.51

Published

A logging library with tools for frontend and backend.

Downloads

12

Readme

WIP : small toolset available / Limited documentation

Chapter 1 : Orwellian

Using Orwellian

Asimovian is mainly designed as a client-side tool, although compatible with backend node applications, to simplify your logging to a single function call, with a unified behaviour - such as uploading them to your distant server.

Goals and practical use

Here is a simple implementation of an Orwellian instance :

import Orwellian from "orwellian";

const options = {

    // This is the same as the default values : 
    appName: string = "default";  //  |
    version: string = "0.0.0";    //  | 
    type: string = "development"; //  | These three values can be anything you'd like,
    // they'll be logged and/or sent back to you on use. 
    // It can prove useful to keep it tidy or automatically linked to your development version,
    // so you can make sure reported errors are linked to your production version.


    callBack: function;           // A callback that'll be fed the data generated from the listener.
    logging: boolean = true;      // Activates or deactivates the logging to the console.
    logLevel: logLevel = 'debug';  //  'debug' | 'error' | 'silent' ; If "logging" is activated, 
    // you can choose to log every event fired, only errors, or none of them to the console.
} 
const orwellian = new Orwellian(options)

Once initialized, the instance gives us access to informations and methods to record data on the fly.

orwellian.listen("I can handle text, but also errors !")
orwellian.listen(() => throw new Error("Record this !"))
process.on("exit", (something) => orwellian.listen(something))

One handy way to use these property is defining a singleton of an Orwellian instance, and feed it information through an exported function.

const orwellian = new Orwellian(options)

export default orwellian.listen;

Or through a customized function depending on your needs :

const orwellian = new Orwellian(options)

export default function customListener(data) {
    orwellian.listen(data);
    return data.id;
    }
export function customErrorListener(fn) {
    orwellian.listen(fn, "my function arguments", ["can go here"])
}

The options object

Orwellian uses a few properties to identify itself, mostly to be able to format logging messages in a convenient way. These will allow you to more easily define different areas where you can use your tracking.

The following example :

import Orwellian from "orwellian";

const options = {

} 
options.appName = "Orwellian Example"
options.version = "0.0.1"
options.type = "development"
const orwellian = new Orwellian(options)
// Event fired at 12:00 GMT
const collectedData = orwellian.listen({hello:"world"}); 
// collectedData = {
//   timestamp: 'Tue, 18 Oct 2022 12:00:00 GMT',
//   appName: 'Orwellian Example',
//   version: '0.0.1',
//   type: 'development',
//   event: { Hello: 'world' },
//   isError: false
// }

Would output this to the console (and to your callback if provided) :

{"timestamp":"Tue, 18 Oct 2022 12:00:00 GMT","appName":"Orwellian Example","version":"0.0.1","type":"development","event":{"Hello":"world"},"isError":false}

Chapter 2 : Asimovian

Using Asimovian

Asimovian is mainly designed as a server-side tool to record your logs in an unified manner, and write or stock them.

Goals and practical use

import {Asimovian} from "orwellian";
const options = {

} 
const asimovian = new Asimovian(options)

Lorem ipsum

Lorem ipsum

Lorem ipsum

Lorem Ipsum

Lorem ipsum

Lorem ipsum

Lorem ipsum

Current limitations

As of right now, Asimovian does not have a reliable way to secure the writing of all messages in a cluster environment. A file accessed at the same time could lead to errors or unwritten messages.

Some optimization is still necessary in many areas to prevent edge cases.

Current Todo :

  • provide documentation
  • provide support or change behaviours with clusters
  • establish a more solid implementation of file management, including filenames
  • research establishing a third tool (gargantuan) as an easy to set up visualizer of the errors
  • buy coffee !