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

react-native-simple-logger

v0.1.1

Published

This is a simple logger for React-Native to log things more clearly using colored logs

Downloads

29

Readme

PRs Welcome

react-native-simple-logger

A simple React-Native logger to log outputs to make debugging easy in Chrome Debugger.

It automatically disables the console.log if it is not in the production environment.

Installation

If using yarn:

yarn add react-native-simple-logger

If using npm:

npm i react-native-simple-logger

Usage

import logger from 'react-native-simple-logger';

Simply change

console.log('I am a log');

to

logger.log('I am a log');

It has different methods to log the out:

1. logger.log

Usage:

let data object be:

const data = {
   id: 1,
   email: '[email protected]',
   name: 'test'
}
  • logger.log(header, text, expandJson)

    header: The header to be shown as heading of the output

    text: The output to be shown

    expandJson: If the output to be shown is JSON object, the JSON object would be expanded by using JSON.stringify().replace() method

  • logger.log(text)

    text: The output to be shown

    If only text is provided, the default heading would be "LOG"

    The default value for expandJson is false

| logger.log('I am a log') | logger.log(null, data, true) | logger.log('User data is: ', data, true) | | ----------------------------- | ------------------------------ | ---------------------------------------- | | | | |

2. logger.error

Usage:

  • logger.error(header, text)

    header: The header to be shown as heading of the output

    text: The output to be shown

  • logger.error(text)

    text: The output to be shown

    If only text is provided, the default heading would be "ERROR"

| logger.error('error is: ', 'I am an error') | logger.error('I am an error') | | ------------------------------------------ | ------------------------------ | | | |

3. logger.apiError

Usage:

  • logger.apiError(header, text)

    header: The header to be shown as heading of the output

    text: The output to be shown

  • logger.apiError(text)

    text: The output to be shown

    If only "text" is provided, the default heading would be "API ERROR"

    This method is made to log the API error for the "axios". The error details would contain the error status code, url, error response etc.

Let api request be:

axios({
    url: 'https://jsonplaceholder.typicode.com/post',
    method: 'post',
    data: {
        title: 'foo',
        body: 'bar',
    },
})
    .then((response) => logger.data('add post response is: ', response.data))
    .catch((error) => logger.apiError('add post error:', error));

Here I have passed the incorrect url https://jsonplaceholder.typicode.com/post, which should be https://jsonplaceholder.typicode.com/posts.

The error will be something like as shown in the 3rd column image below:

| logger.apiError(error) | logger.apiError(error) | logger.apiError('add post error:', error) | | ---------------------------------- | ----------------------------------- | ----------------------------------------- | | | | |

4. logger.data

Usage:

  • logger.data(header, text, noJsonExpand)

    header: The header to be shown as heading of the output

    text: The output to be shown

    noJsonExpand: A boolean indicating wether to expand the JSON output into more clearer view

  • logger.data(text)

    text: The output to be shown

    If only "text" is provided, the default heading would be "DATA" The default value for noJsonExpand is false i.e. the output would be expanded

| logger.data('User data is:', data) | logger.data('User data is:', data, true) | logger.data(data) | | ---------------------------------- | ----------------------------------------- | ------------------------------ | | | | |