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

@vygruppen/ts-logger

v0.0.5

Published

A logging framework for Vy's frontend libraries

Downloads

662

Readme

Vy frontend logging library for TypeScript

This library makes is simple to log messages, errors and other data to Vy's frontend logging service.

Installation

npm install @vygruppen/ts-logger

Usage

Create a logger instance and use it to log whatever you want. You have to specify what app you are logging from.

import { getLogger } from '@vygruppen/ts-logger';
const logger = getLogger({ source: 'my-app' });

try {
  logger.debug('Details details');
  logger.info('This is going fine');
  logger.warn({ message: 'Oh crap wait' }));
}
catch (e) {
  logger.error({ message: 'Ah shucks.', data: e }));
}

Note that you can both pass a single string argument, or an object in the shape of { message: string, data?: any } to the logging functions.

You can also specify what environment you are logging from, if you want to override that for whatever reason:

import { getLogger } from "@vygruppen/ts-logger";
const logger = getLogger({ source: "my-app", environment: "wonky" });

Override the URL

By default, the logger will log to the relative URL /web-services/web-logger, but you can override this by passing a url option to the getLogger function.

import { getLogger } from "@vygruppen/ts-logger";
const logger = getLogger({
  source: "my-app",
  url: "https://my-log-service.com",
});

Note that the URL will still be called as a POST with the same JSON body. If you need something different, you probably should fork this library and create your own. It's not a lot of code.

Async function

Since this triggers a network request, the logging functions are async. There shouldn't be any reasons to wait for the request to finish, but you can if you have a particular reason to do so.

Singleton

The logger is a singleton, so you can create it as many times as you like without any performance penalty.

Development

This package is based on Vite, and uses TypeScript. To get started, clone the repo, install dependencies with npm install and run the dev server:

npm run dev

This will open a live-reloading dev server, with an interactive playground where you can test your changes.

Release

This project uses Changesets for releases. Read more about Changesets here.

To create a new release, open a pull request, and add a changeset file. Typically, you'd want to do this through the GitHub UI, or you can run npx changeset locally to get started.

Once you've added a changeset, you can merge your pull request. This will trigger a GitHub Action that will create a new pull request, which, when merged, will trigger a new release. The release will be published to NPM, and a new GitHub release will be created.

Questions?

If you have any questions, get in touch with @selbekk.