log-rect
v1.0.0
Published
A react library to beautify your logs
Downloads
2
Readme
log-rect
A react library to beautify your logs
Install
npm install --save log-rect
or
yarn add log-rect
Usage
import "./index.css";
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import { LogRect } from "log-rect";
ReactDOM.render(
<LogRect mode="DEV">
<App />
</LogRect>,
document.getElementById("root")
);
import React, { useEffect } from "react";
import { useLogger } from "log-rect";
import "log-rect/dist/index.css";
const App = () => {
const { logger } = useLogger();
useEffect(() => {
const interval = setInterval(() => {
logger({ type: "INFO", data: ["Hello World"], name: "gjshef" });
}, 5 * 1000);
return () => clearInterval(interval);
});
return <div>My React App</div>;
};
export default App;
Props -> LogRect
- mode -> "DEV" || "PROD" ---> if mode === 'PROD' log panel will not be shown
Data type for logs
- name: string ---> not required
- type: 'INFO' | 'ERROR' | 'WARN' --> defines different log level
- data: any ---> actual content to show within log/ log content
License
MIT © jamilur-r