UNPKG

@devgalena/react-use-logger

Version:

`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

39 lines (23 loc) 1.24 kB
# 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 ```jsx 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. ```jsx 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