@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
26 lines (25 loc) • 1.24 kB
TypeScript
import { default as React } from 'react';
import { LoggingLevel, RenderLoggerFnType } from './types';
/**
* @see {@link LoggingContextProvider}
*/
export type LoggingContextProviderArgType = {
level?: LoggingLevel;
render?: RenderLoggerFnType;
children: React.ReactNode;
};
/**
*
* Provide a LoggingContext to consume and use the `useLogger` react hook.
* @see `useLogger` for details about the React Hook
* @see {@link LoggingContext} for more details about the logging context
* @example <caption>Logs messages at levels - info and above only</caption>
* <LoggingContextProvider level={LoggingLevel.Info}>
* <ComponentUsingLogger></ComponentUsingLogger>
* </LoggingContextProvider>
* @param {LoggingContextProviderArgType} root0 Arguments to LoggingContextProvider
* @param {LoggingLevel} root0.level The logging level to be configured to be logged. Used by `useLogger` hook.
* @param {React.ReactNode} root0.children Child Component consuming the `LoggingContext` provided by this component
* @returns {React.ReactNode} Returns a React Component that provides LoggingContext
*/
export declare const LoggingContextProvider: ({ level, render, children, }: LoggingContextProviderArgType) => React.ReactNode;