SyysBiir / react-terminal-logger

Simple console logger for vue, react and react-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React terminal logger

npm

Simple console logger for vue, react and react-native

New Features!

  • Saving logs to a file (optional)
  • Short alias for console.log

Getting Started

To install the module, run the following in the command line:

npm i react-terminal-logger --save

Use within your application with the following line of JavaScript:

const ReactLogger = require('react-terminal-logger/console-logger');

or

import ReactLogger from 'react-terminal-logger/console-logger'

Run this command in your project's index file:

ReactLogger.start(); //Quick start with standard configuration

To run the logger in the terminal, you need to run the command in your project directory:

npx react-terminal-logger

You can specify the port on which the logger will run:

npx react-terminal-logger --p=1234

Configuration

You can specify what information to show in the terminal:

ReactLogger.start(
    ["log", "error", "info", "warn", "logr"], //You can specify what information to show in the terminal
    true, //Save logs to a file. Your logs will be saved in directory react-logger-logs. Default: false
    true, //Show only message in terminal. Ignores the value of stacktrace_hide. Default: false
    1234, //Port on which the logger is running. Default: 1234
    true //Hide stacktrace. Default: false
);

or

ReactLogger.config({
    visible : ["log", "error", "info", "warn", "logr"], //You can specify what information to show in the terminal
    save_logs: true, //Save logs to a file. Your logs will be saved in directory react-logger-logs. Default: false
    only_msg : true, //Show only message in terminal. Ignores the value of stacktrace_hide. Default: false
    port: 1234, //Port on which the logger is running. Default: 1234
    stacktrace_hide: true //Hide stacktrace. Default: false
});
ReactLogger.start();

In addition to the standard console.log, console.info, console.error, console.warn added a quick command for logging:

logr("your log"); //window.logr("your log")
logr("your log", 1, [{"a1": 1}]); //window.logr("your log", 1, [{"a1": 1}])

You can use this command anywhere, it is enough to include our module in the index file.

About

Simple console logger for vue, react and react-native


Languages

Language:JavaScript 100.0%