-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add setDefaultLogger func and change @retryable decorator not to initialize logger before first use of function Also remove `pino-pretty` from examples package due to defined declaration in `pino-pretty` downgrade pino to make tests working on node 10.x.x Addresses #191
- Loading branch information
Showing
7 changed files
with
305 additions
and
555 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {main} from '../utils'; | ||
import {Logger, LogFn, Driver, getCredentialsFromEnv, setDefaultLogger} from 'ydb-sdk'; | ||
|
||
const logFunction: LogFn = (obj: any, ...args: any[]) => { | ||
console.log('Custom logging!', obj, ...args) | ||
}; | ||
const MyLogger: Logger = { | ||
fatal: logFunction, | ||
error: logFunction, | ||
warn: logFunction, | ||
info: logFunction, | ||
debug: logFunction, | ||
trace: logFunction | ||
} | ||
|
||
setDefaultLogger(MyLogger) | ||
|
||
export async function run(logger: Logger, endpoint: string, database: string) { | ||
logger.info('Driver initializing...'); | ||
const authService = getCredentialsFromEnv(); | ||
const driver = new Driver({endpoint, database, authService}); | ||
const timeout = 10000; | ||
if (!await driver.ready(timeout)) { | ||
logger.fatal(`Driver has not become ready in ${timeout}ms!`); | ||
process.exit(1); | ||
} | ||
logger.info('Done'); | ||
driver.destroy() | ||
|
||
} | ||
|
||
main(run); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.