index.d.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { LogContext } from './context';
  2. import { LogMessageTranslator } from './message';
  3. import { LogTarget } from './target';
  4. interface LogMethod {
  5. (message: string, ...args: any[]): void;
  6. (context: LogContext, message: string, ...args: any[]): void;
  7. isEmptyFunction?: boolean;
  8. }
  9. interface LogChildMethod {
  10. (context: LogContext): Logger;
  11. (translate: LogMessageTranslator): Logger;
  12. }
  13. interface LogWrapMethod {
  14. <F extends (...args: any[]) => any>(func: F): F;
  15. <F extends (...args: any[]) => any>(message: string, func: F): F;
  16. <F extends (...args: any[]) => any>(context: LogContext, message: string, func: F): F;
  17. <F extends (...args: any[]) => any>(level: number, message: string, func: F): F;
  18. }
  19. interface Logger extends LogMethod {
  20. trace: LogMethod;
  21. debug: LogMethod;
  22. info: LogMethod;
  23. warn: LogMethod;
  24. error: LogMethod;
  25. fatal: LogMethod;
  26. child: LogChildMethod;
  27. wrap: LogWrapMethod;
  28. }
  29. declare const resetSequence: (next?: number) => void;
  30. declare const lastSequenceNumber: () => number;
  31. interface CreateLoggerOptions {
  32. context?: LogContext;
  33. translate?: LogMessageTranslator;
  34. targets?: string | LogTarget[];
  35. }
  36. declare const createLogger: ({ context: baseContext, targets: logTargets, translate: logTranslator, }?: CreateLoggerOptions) => Logger;
  37. export { createLogger, lastSequenceNumber, Logger, LogMethod, resetSequence, CreateLoggerOptions };