How to use the @tinkoff/utils/object/pick function in @tinkoff/utils

To help you get started, we’ve selected a few @tinkoff/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TinkoffCreditSystems / tinkoff-request / packages / plugin-log / src / log.ts View on Github external
interface Logger {
    info: LogFunction;
    debug: LogFunction;
    error: LogFunction;
}

const defaultLogger = (name: string): Logger => {
    return {
        info: (...args) => console.info(name, ...args), // tslint:disable-line:no-console
        debug: (...args) => console.debug(name, ...args), // tslint:disable-line:no-console
        error: (...args) => console.error(name, ...args), // tslint:disable-line:no-console
    };
};

const getInfo = pick(['url', 'query', 'payload']);

/**
 * Logs request events and timing
 *
 * requestParams:
 *      silent {boolean}
 *
 * metaInfo:
 *      log.start {number} - request start Date.now()
 *      log.end {number} - request end Date.now()
 *      log.duration {number} - request duration (end - start)
 *
 * @param name {string}
 * @param logger {Function} - logger factory
 * @return {{init: init, complete: complete, error: error}}
 */