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

@renanmalato/logger-plus

v1.2.10

Published

A powerful and easy-to-use logging utility for React Native and Expo applications. @renanmalato/logger-plus provides a consistent way to log messages with different levels of severity (info, success, warning, error) and includes timestamps for each log en

Downloads

54

Readme

@renanmalato/logger-plus

This custom logger provides a breathable and consistent way to log messages with different levels of severity (info, success, warn, error) and includes timestamps for each log entry. It is a very light weight library designed specifically for React Native and Expo projects Javascript but it also can be used in TypeScript and CommonJS.

Discussion and Support

If you have something to contribute please visit our GitHub repository. If you consider this package helpful also you can consider support on the Buy Me a Coffee shield.

Installation

First, ensure you have the @renanmalato/logger-plus package in your project by installing it via npm:

npm install @renanmalato/logger-plus

Usage

Importing the Logger

For React Native Import using Expo:

import Logger from '@renanmalato/logger-plus';

For Common Javascript (CommonJS):

const Logger = require('@renanmalato/logger-plus');

Image of the package logging

Logging Methods

The Logger provides several methods for logging messages:

• 1st Case: Message and Screen name

  • Logger.log('Message goes here', 'Screen or Function Name');

• 2nd Case: Message, Screen name and Variable

  • Logger.info('Message goes here', 'Screen or Function Name', variable);

• 3rd Case: Logs only Message

  • Logger.info('Message goes here');

• 4th Case: Log Success with Object

  • Logger.success('Message goes here', 'Screen or Function Name', object);

• 5th Case: Log Box

  • Logger.box('Debug here', 'Screen or Function Name');

More cases...

  • Logger.log(message, screenOrFunction, ...messages)
  • Logger.success(message, screenOrFunction, ...messages)
  • Logger.info(message, screenOrFunction, ...messages)
  • Logger.warning(message, screenOrFunction, ...messages)
  • Logger.error(message, screenOrFunction, ...messages)
  • Logger.line(message, ...messages)
  • Logger.box(message, ...messages)

(knowing issue - Logger.line in some screens warn no formatText variable found. Working on it. Use Logger.log for more simple logging instead or console.log)

.

Parameters

  • message (string): The primary log message.
  • screenOrFunction (string, optional): The source of the log message, such as the screen or function name. If omitted, defaults to (not called).
  • variable (values / objects): Log variable values.

Examples

Basic Usage

import Logger from '@renanmalato/logger-plus';

const variable = "string variable";

// Basic log
Logger.log('This is a simple log message');

// Info log with source
Logger.info('Fetching data:', 'DataScreen');

// Success log
Logger.success('Data fetched successfully:', 'DataScreen', variable);

// Warn log
Logger.warn('Data fetch took too long:', 'DataScreen');

// Error log
Logger.error('Failed to fetch data:', 'DataScreen', variable);

// Line log (without source)
Logger.line('This is a simple line log');

// Line box
Logger.box('This is a box log');

Detailed Example

import React from 'react';
import { View, Text } from 'react-native';
import Logger from '@renanmalato/logger-plus';

const ExampleComponent = () => {
  const variable = "string variable";
  const object = {
    name: 'Renan',
    age: 23,
  };


  useEffect(() => {
    Logger.info('Message:', 'App.js');
    Logger.info('Message:', 'App.js', variable);
    Logger.info('Object:', 'App.js', object);
    Logger.info(variable);
    Logger.success('Successfully updated cart count to', 'CartScreen', variable);
    Logger.warning('Warning: Cart count is getting high', 'CartScreen', object);
    Logger.error('Error: Something went wrong with cart count', 'CartScreen', variable);
    Logger.log('Logging a simple message');
    Logger.line('This is a simple line log');
    Logger.box('Debug Here');

  }, []);

  return (
    <View>
      <Text>Hello, world!</Text>
    </View>
  );
};

export default ExampleComponent;

Contributing

If you encounter any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on GitHub.

License

Created by renanmalato This project is licensed under the MIT License.