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

tamarine

v1.0.0

Published

A simple node logger library

Downloads

3

Readme

Tamarine

Tamarine is a simple Node.js logging library, inspired on https://github.com/asolera/loggr.

It allows you to:

  • define any combination of log levels/types;
  • create custom log types.

It supports, by default, the following levels: INFO, NOTICE, WARNING, ERROR, FATAL, DEBUG, SQL.

Getting Started

Install Tamarine in your project:

npm i tamarine

Start logging:

const logger = require('tamarine')

logger.info(logger.line())
logger.info('Hello world!')
logger.info(logger.line())

Code output:

2020-6-15 15:10:06 [INFO] ================================================================================
2020-6-15 15:10:06 [INFO] Hello world!
2020-6-15 15:10:06 [INFO] ================================================================================

Configuring Log Levels

Tamarine allows you to configure allowed levels in a simple string, joined by pipe operator, thus making simpler for working with different environments.

By default (wthout any configuration) only info, error and fatal logs will be printed in console.

Call the method below (at the very beggining of your script), passing in the desired log levels:

const logger = require('tamarine')

logger.setAllowedLogs('info|error|debug')

logger.debug('It works!')

You can also define all (all log types will be printed) or none (disable any logging) options.

Creating custom types

You can also define a custom type of log by calling this method before configuration (setAllowedLogs):

const logger = require('tamarine')

logger.setCustomLog("example")
logger.setAllowedLogs('info|error|example')

logger.custom('example', 'It works!')

Output:

2020-6-15 15:10:06 [EXAMPLE] It works!

Custom types are also subject for allowed types configuration and must be called before anything.

Logging

Docs by example:

const logger = require('tamarine')

logger.setCustomLog("test")
logger.setAllowedLogs("all") // this is needed in order to print all the messages below

logger.info(logger.line()) // prints a line inside an info message
logger.info("Info message...")
logger.notice("Notice message...")
logger.warning("Warning message...")
logger.error("Error message...")
logger.fatal("Fatal message...")
logger.debug("Debug message...")
logger.sql("SELECT something FROM example")
logger.custom("test", "A custom log type message...")
logger.info(logger.line())

Output:

2020-6-15 16:39:24 [INFO] ================================================================================
2020-6-15 16:39:24 [INFO] Info message...
2020-6-15 16:39:24 [NOTICE] Notice message...
2020-6-15 16:39:24 [WARNING] Warning message...
2020-6-15 16:39:24 [ERROR] Error message...
2020-6-15 16:39:24 [FATAL] Fatal message...
2020-6-15 16:39:24 [DEBUG] Debug message...
2020-6-15 16:39:24 [SQL] SELECT something FROM example
2020-6-15 16:39:24 [TEST] A custom log type message...
2020-6-15 16:39:24 [INFO] ================================================================================

Full Documentation

| Method | Default | Description | |---|---|---| | setCustomLog(typeName) | | Allows to create a custom log type.A custom type called example will be converted to [EXAMPLE].Custom types should also be defined in setAllowedLogs in order to be printed.This method must be declared BEFORE setAllowedLogs method. | | setAllowedLogs(logTypes) | info|error|fatal | Defines which log types will be printed.You can use any combination you want. Log types must be joined by pipe (|).You can also use none to disable logging and all to automatically enable all log types. | | line() | | Prints a line. | | info(message) | | Prints the message with [INFO] prefix. | | notice(message) | | Prints the message with [NOTICE] prefix. | | warning(message) | | Prints the message with [WARNING] prefix. | | error(message) | | Prints the message with [ERROR] prefix. | | fatal(message) | | Prints the message with [FATAL] prefix. | | debug(message) | | Prints the message with [DEBUG] prefix. | | sql(message) | | Prints the message with [SQL] prefix. | | custom(typeName, message) | | Prints the message with a custom prefix.In order to work, the custom log type must be set in setCustomLog method and defined in setAllowedLogs method.First argument is prefix and second argument is the message. Multiple custom log types are also allowed. |

Contributing

  1. Fork it
  2. Download your fork to your PC (git clone https://github.com/asolera/tamarine && cd tamarine)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Make changes and add them (git add .)
  5. Commit your changes (git commit -m 'Add some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new pull request

Author

Andrew Solera - [email protected]