mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add type declarations for [bristol] logger (#38042)
* [bristol] Added types for bristol logger * [bristol] made recommended changes for most common use cases
This commit is contained in:
parent
3edb6857d0
commit
a1b4916891
17
types/bristol/bristol-tests.ts
Normal file
17
types/bristol/bristol-tests.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import bristol = require('bristol');
|
||||
|
||||
bristol.addTarget('console');
|
||||
bristol.info('Things be working.', {});
|
||||
|
||||
bristol.addTarget('console').withFormatter('human');
|
||||
bristol.debug('Hello, world', { code: 404 });
|
||||
|
||||
const uhoh = {
|
||||
code: 500,
|
||||
error: {
|
||||
message: 'Something broke',
|
||||
reason: 'idk why though',
|
||||
},
|
||||
};
|
||||
|
||||
bristol.error('Something went wrong', uhoh);
|
||||
36
types/bristol/index.d.ts
vendored
Normal file
36
types/bristol/index.d.ts
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
// Type definitions for bristol 0.4
|
||||
// Project: https://github.com/TomFrost/Bristol
|
||||
// Definitions by: Eric Heikes <https://github.com/eheikes>
|
||||
// Elliott Campbell <https://github.com/ElliottCampbellJHA>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Caveat: Currently, .d.ts files are unable to handle this package fully
|
||||
// as it requires both class and namespace be exported.
|
||||
|
||||
interface LogError {
|
||||
message?: string;
|
||||
reason?: any;
|
||||
stack?: any;
|
||||
}
|
||||
|
||||
interface LogData {
|
||||
code?: number;
|
||||
id?: string;
|
||||
path?: string;
|
||||
error?: LogError;
|
||||
data?: any;
|
||||
}
|
||||
|
||||
declare class Bristol {
|
||||
addTarget(target: any, opts?: any): any;
|
||||
withFormatter(formatter: string): any;
|
||||
withLowestSeverity(severity: string): any;
|
||||
info(message: string, data: LogData): any;
|
||||
warn(message: string, data: LogData): any;
|
||||
error(message: string, data: LogData): any;
|
||||
debug(message: string, data: LogData): any;
|
||||
}
|
||||
|
||||
declare const bristol: Bristol;
|
||||
|
||||
export = bristol;
|
||||
23
types/bristol/tsconfig.json
Normal file
23
types/bristol/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"bristol-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/bristol/tslint.json
Normal file
1
types/bristol/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user