@devgalena/react-use-logger
TypeScript icon, indicating that this package has built-in type declarations

0.1.7 • Public • Published

React Use Logger Hook

react-use-logger is a React hook to log messages. It also contains a function useLogger and a class LoggingContextProvider to set the logging levels of the library / application

For an equivalent and a recent version of the documentation with more examples, please visit the web site at https://devgalena.com/react-hooks/use-logger

import { useLogger } from "@devgalena/react-use-logger";


const {debug, info, warning, error} = useLogger();
debug("This is a debug log message");
info("This is a info log message");
warning("This is a warning log message");
error("This is a error log message");

Configure the logging level

To configure the logging level, set the LoggingContext ( level member ) as appropriate.

For example, use the LoggingContextProvider to set the logging level for components under the same.

  import { LoggingContext, LoggingLevel } from "@devgalena/react-use-logger";

    <LoggingContextProvider
      level={LoggingLevel.Info}
    >
      {children}
    </LoggingContextProvider>

For an equivalent and a recent version of the documentation with more examples, please visit the web site at https://devgalena.com/react-hooks/use-logger

Package Sidebar

Install

npm i @devgalena/react-use-logger

Weekly Downloads

5

Version

0.1.7

License

MIT

Unpacked Size

10.8 kB

Total Files

15

Last publish

Collaborators

  • hellokarthik