target-mock.d.ts 1.0 KB

12345678910111213141516171819202122232425262728
  1. import { LogMessage } from '../logger/message';
  2. import { LogTarget } from '../logger/target';
  3. interface ExtendedArray<T> extends Array<T> {
  4. readonly last: T | undefined;
  5. }
  6. interface LogLevelMap<T> {
  7. trace: T;
  8. debug: T;
  9. info: T;
  10. warn: T;
  11. error: T;
  12. fatal: T;
  13. }
  14. declare const extendArray: <T>(array: T[]) => ExtendedArray<T>;
  15. declare class LogTargetMock implements LogTarget {
  16. minLevel: number;
  17. readonly messages: ExtendedArray<LogMessage> & LogLevelMap<ExtendedArray<LogMessage>>;
  18. readonly lines: ExtendedArray<string> & LogLevelMap<ExtendedArray<string>>;
  19. readonly stream: LogTarget['stream'];
  20. constructor(minLevel?: number);
  21. format(msg: LogMessage): string;
  22. clear(): void;
  23. filteredMessages(level: number, untilLevel?: number): ExtendedArray<LogMessage>;
  24. filteredMessages(level: null): ExtendedArray<LogMessage>;
  25. filteredLines(level: number, untilLevel?: number): ExtendedArray<string>;
  26. filteredLines(level: null): ExtendedArray<string>;
  27. }
  28. export { LogTargetMock, extendArray, ExtendedArray };