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

@arateg/logger

v1.1.1

Published

A logger that supports colors, date rotate, custom log handlers

Downloads

5

Readme

CUSTOMIZED COLOR LOGGER

The logger has opportunities to print color messages and also send emails or messages to slack

You can write your own method names of logger and they are supported!

Install

$ npm i @arateg/logger --save

Usage

File .env must contain 5 values:

  1. SMTP_USER - string. User who will send messages.
  2. SMTP_PASS - string. Password for smtp user.
  3. SMTP_HOST - string. SMTP host service.
  4. EMAIL_RECEIVERS - string or array. Emails for messages.
  5. LOG_FOLDER - string. Folder to save log files.
  6. SLACK_ACCESS_TOKEN - string. Access token from your application in slack.
  7. SLACK_RECEIVER - string. ID of person or channel in slack where to send messages.
  8. DOMAIN - string. Domain name which is used in email message header on email log level
.env example
SMTP_USER='[email protected]'
SMTP_PASS='password'
SMTP_HOST='smtp.gmail.com'
EMAIL_RECEIVERS='[email protected]'
LOG_FOLDER='/var/logs/myapp'
SLACK_ACCESS_TOKEN='xoxp-111111111111-111111111111-111111111111-111111111111aaaaaaaaaaaaaaaaaaaa'
SLACK_RECEIVER='ZZZZZZZZZ'
DOMAIN='mysite.com'
index.js
const logger = require('@arateg/logger');
logger.iWantInfo('Message for admin', { something: 'Hello', someField: 'Great!' });
logger.warnLogWithEmail('Print and send Mail', { error: 'No error', sweetCakes: 'Give me 3!!!' });
logger.letMeSlackNotify('Message in slack please', { thisLoggerRank: 'GOAT' });

API

logger.<method>(string, object)

How it works:

 1. The logger has some keyword:
   + daemon
   + info
   + email
   + error
   + full
   + slack
   + warn
 2. Combine these words with any other words you want and create convient method name.
 3. Add a string as the 1st argument(message) and an object as the 2nd.
 4. Timestamp in format DD-MM-YYYY HH:mm:ss (31/12/2018 23:59:59) will be added automatically.
 5. You receive a colored message (and email send if needed and configured).

Description of keyword(log levels):

  • "daemon" - print log in green #28C865 color. Has debug log level.
  • "info" - print log in cyan #1DC7CF color. Has info log level.
  • "email" - send a message with report to email. Print message of successful in yellow #E3DA14 color. If some error when sending print message in red #EE4218 color to console.
  • "error" - print log in red #EE4218 color. Has error log level.
  • "full" - print log in gray #A1A1A1 color. Has silly log level.
  • "slack" - send a message with report to slack. Print message of successful in yellow #E3DA14 color. If some error when sending print message in red #EE4218 color to console.
  • "warn" - print log in magenta #CE5CFF color. Has warn log level.

Log files:

Logger creates a folder for logs regarding LOG_FOLDER in .env file. If LOG_FOLDER is not existed in .env file then logs will be saved in process.cwd() + /logs directory. There is a message in console ===== New log file ===== when new file is created each day.
Logger creates a new 2 files each day, where %DATE% has a format YYYY-MM-DD. :

  • LogError-%DATE%.log. These files are related to error log level.
  • LogCombined-%DATE%.log. These files are related to silly log level.