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

log_docs

v1.0.1

Published

Log Docs is a TypeScript package that provides logging functionality for documenting activities in your application. It allows you to connect to a MongoDB database and log various events with customizable details.

Downloads

1

Readme

Log Docs (TypeScript)

Log Docs is a TypeScript package that provides logging functionality for documenting activities in your application. It allows you to connect to a MongoDB database and log various events with customizable details.

Installation

To use Log Docs in your TypeScript project, you need to install it using npm:

npm install log_docs

Usage

Import the logger module from log_docs in your TypeScript file:

import * as logger from 'log_docs';

Environment Variables

The following environment variables are used by Log Docs:

  • DATABASETYPE: Specifies the type of database to connect to (e.g., "mongodb").
  • EXPIRE_SEC: Sets the number of seconds after which database records should be deleted.

Make sure to configure these environment variables before using the logger.

Logging Functions

Connect to the Database

To establish a connection to the MongoDB database, use the following syntax:

logger.connect(connectionString: string);

Replace connectionString with the appropriate connection string for your MongoDB database.

Log Activity

To log an activity, use the activity function with the following parameters:

logger.activity(
  key: string,
  event: string,
  sub_event: string,
  event_response: string,
  event_status: string
);
  • key: A unique identifier for the activity.
  • event: The main event being logged.
  • sub_event: A sub-event or additional information related to the main event.
  • event_response: The response or result of the event.
  • event_status: The status of the event (e.g., success, failure).

Example

Here's an example of how to use Log Doc in a TypeScript project:

import * as logger from 'log_docs';

logger.connect('mongodb://localhost:27017/mydatabase');

logger.activity(
  '123456',
  'User Login',
  'Authentication',
  'Login successful',
  'Success'
);

This will log a successful user login activity in the connected MongoDB database.

Remember to configure the appropriate environment variables and ensure that your MongoDB server is running before using the logger.

For further information or support, please refer to the package documentation or contact the package author.