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

25 lines (24 loc) 709 B
import { LoggingLevel } from './types'; export type LogFunctionType = (s: string) => void; /** * */ export interface UseLoggerType { level?: LoggingLevel; debug: LogFunctionType; info: LogFunctionType; warning: LogFunctionType; error: LogFunctionType; } /** * React Hook to use a logger * @example * const {debug, info, warning, error, level} = useLogger(); * debug("Debug statement"); * info("Info log"); * warning("Warning log"); * error("This is an error"); * console.log(level); // Current LoggingLevel set by LoggingContextProvider * @returns {UseLoggerType} Returns multiple loggers - debug, info, warning and error */ export declare function useLogger(): UseLoggerType;