Skip to content

Commit

Permalink
fix: make logger type broader
Browse files Browse the repository at this point in the history
  • Loading branch information
SaurusXI committed Feb 16, 2023
1 parent f844e75 commit 523cfff
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import { Cluster, Redis } from "ioredis";
import readFunctionParams from '@captemulation/get-parameter-names';
import { dummyLogger, Logger } from 'ts-log';
import { RedisConstants, RedisExpiryModes } from "./constants";
import { dummyLogger, Logger } from './types/logging';
import { RedisExpiryModes } from "./constants";
import { CacheResultParams, CreateCacheOptions, InvalidateFromCacheParams, TTL } from "./types";

export class SugarCache {
Expand Down
25 changes: 25 additions & 0 deletions lib/types/logging.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

/**
* Represents a generic logger that could be a simple console, bunyan etc.
*/
export interface Logger {
debug(message?: any, ...optionalParams: any[]): void;
info(message?: any, ...optionalParams: any[]): void;
warn(message?: any, ...optionalParams: any[]): void;
error(message?: any, ...optionalParams: any[]): void;
[x: string]: any;
}

/**
* Dummy logger that does not do anything.
*
* Useful as a default for some library that the user might want to get logs out of.
*/
export const dummyLogger: Logger = {
trace: (_message?: any, ..._optionalParams: any[]) => {},
debug: (_message?: any, ..._optionalParams: any[]) => {},
info: (_message?: any, ..._optionalParams: any[]) => {},
warn: (_message?: any, ..._optionalParams: any[]) => {},
error: (_message?: any, ..._optionalParams: any[]) => {},
};

13 changes: 1 addition & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"test": "jest --runInBand --forceExit"
},
"dependencies": {
"@captemulation/get-parameter-names": "^1.4.2",
"ts-log": "^2.2.5"
"@captemulation/get-parameter-names": "^1.4.2"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 523cfff

Please sign in to comment.