How to use beaver-logger - 10 common examples

To help you get started, we’ve selected a few beaver-logger 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 paypal / paypal-checkout-components / src / hacks.js View on Github external
Checkout.renderTo = (win) => {
        info('force_ie_full_page');
        flushLogs();

        // $FlowFixMe
        const checkout = Checkout.init({
            onAuthorize: noop
        });

        checkout.delegate(win);

        checkout.openContainer().then(() => {
            checkout.event.triggerOnce(CONSTANTS.EVENTS.CLOSE);
            checkout.showContainer();
        });

        // $FlowFixMe
        Button.xprops.payment().then(token => {
github paypal / paypal-checkout-components / src / legacy / common.js View on Github external
/* @flow */

import { prefix } from 'beaver-logger/client';

import { config } from '../config';
import { COUNTRY, LANG } from '../constants';
import type { LocaleType } from '../types';

import { LOG_PREFIX } from './constants';

let { warn } = prefix(LOG_PREFIX);

const DEFAULT_COUNTRY = COUNTRY.US;
const DEFAULT_LANG = LANG.EN;

export function normalizeLocale(locale : string) : LocaleType {

    let [ lang, country ] = locale.split('_');

    if (!country) {
        if (config.locales[lang]) {
            country = lang;
            lang = null;
        } else {
            country = DEFAULT_COUNTRY;
        }
    }
github paypal / paypal-checkout-components / src / legacy / util.js View on Github external
/* @flow */

import { ZalgoPromise } from 'zalgo-promise/src';
import { flush as flushLogs, prefix } from 'beaver-logger/client';

import { config } from '../config';
import { ENV } from '../constants';
import { urlWillRedirectPage, redirect as redir } from '../lib';

import { LOG_PREFIX } from './constants';

let { warn } = prefix(LOG_PREFIX);

let redirected = false;

export function logRedirect(location : string) {

    if (redirected) {
        warn(`multiple_redirects`);
    }

    if (urlWillRedirectPage(location)) {
        redirected = true;
    }

    flushLogs();
}
github paypal / paypal-checkout-components / src / legacy / options.js View on Github external
/* @flow */

import { prefix } from 'beaver-logger/client';

import { config } from '../config';
import { ENV } from '../constants';
import { getElements } from '../lib';

import { normalizeLocale } from './common';
import { LOG_PREFIX } from './constants';

let { info, warn } = prefix(LOG_PREFIX);

export function normalizeOptions(options : Object) {

    // Normalize environment

    if (options.environment) {

        if (options.environment === 'live') {
            options.environment = ENV.PRODUCTION;
        }

        if (!config.paypalUrls[options.environment]) {
            warn('invalid_env', { badenv: options.environment });
            options.environment = config.env;
        }
    }
github paypal / paypal-checkout-components / src / legacy / ready.js View on Github external
/* @flow */

import { prefix } from 'beaver-logger/client';

import { onDocumentReady } from '../lib';
import { ENV } from '../constants';

import { LOG_PREFIX, ATTRIBUTES, CLASSES } from './constants';
import { setup } from './interface';

let { error, debug } = prefix(LOG_PREFIX);

/*  PayPal Checkout Ready
    ---------------------

    Call window.paypalCheckoutReady on document ready, if it has been defined by the merchant
*/

function invokeReady(method) {

    onDocumentReady(() => {
        debug(`paypal_checkout_ready`);
        setTimeout(() => {

            if (!window.paypal) {
                error(`paypal_checkout_ready_no_window_paypal`);
            }
github paypal / paypal-checkout-components / src / legacy / interface.js View on Github external
import { ZalgoPromise } from 'zalgo-promise/src';
import { prefix, flush as flushLogs } from 'beaver-logger/client';

import { Checkout } from '../checkout';
import { config } from '../config';
import { ENV, FPTI } from '../constants';
import { supportsPopups, once, safeJSON, extendUrl, stringifyError } from '../lib';

import { setupPostBridge } from './postBridge';
import { isLegacyEligible } from './eligibility';
import { LOG_PREFIX } from './constants';
import { renderButtons, getHijackTargetElement } from './button';
import { redirect, logRedirect, parseToken } from './util';
import { normalizeOptions, setupConfig } from './options';

let { info, debug, warn, error, track } = prefix(LOG_PREFIX);

export let checkout = {};
export let apps = { checkout, Checkout: checkout };

export function reset() {

    debug('reset');

    // Once our callback has been called, we can set the global methods to their original values

    checkout.initXO    = initXO;    // eslint-disable-line no-use-before-define
    checkout.startFlow = startFlow; // eslint-disable-line no-use-before-define
    checkout.closeFlow = closeFlow; // eslint-disable-line no-use-before-define
}

checkout.reset = reset;
github paypal / paypal-checkout-components / src / legacy / button.js View on Github external
/* @flow */

import { prefix } from 'beaver-logger/client';
import { ZalgoPromise } from 'zalgo-promise/src';

import { config } from '../config';
import { FPTI, BUTTON_COLOR, BUTTON_SHAPE, BUTTON_SIZE, BUTTON_LABEL } from '../constants';
import { loadScript, memoize, isElementVisible, stringifyError } from '../lib';

import { LOG_PREFIX } from './constants';
import { normalizeLocale } from './common';

let { info, debug, error } = prefix(LOG_PREFIX);

let loadButtonJS = memoize(() : ZalgoPromise => {

    debug(`buttonjs_load`);

    return loadScript(config.buttonJSUrl).catch(err => {
        info(`buttonjs_load_error_retry`, { error: stringifyError(err) });
        return loadScript(config.buttonJSUrl);
    }).then(result => {
        debug(`buttonjs_load_success`);
        return result;
    }).catch(err => {
        error(`buttonjs_load_error`, { error: stringifyError(err) });
        throw err;
    });
});
github magma / magma / nms / app / fbcnms-packages / fbcnms-ui / utils / Logging.js View on Github external
export const ServerLog = (topic: string) =>
  beaver.Logger({
    url: '/logger/' + topic,
    logLevel: beaver.LOG_LEVEL.INFO,
    flushInterval: 10 * 1000,
    // eslint-disable-next-line flowtype/no-weak-types
    transport: async ({url, method, json}): Promise =>
      axios({
        method,
        url,
        data: json.events.map(e => {
          const {event, level, payload} = e;
          const {timestamp, data, user} = payload;
          return {
            event,
            level,
            ts: timestamp / 1000,
            data,
            ...user,
          };
github magma / magma / nms / app / fbcnms-packages / fbcnms-ui / utils / Logging.js View on Github external
export const ServerLog = (topic: string) =>
  beaver.Logger({
    url: '/logger/' + topic,
    logLevel: beaver.LOG_LEVEL.INFO,
    flushInterval: 10 * 1000,
    // eslint-disable-next-line flowtype/no-weak-types
    transport: async ({url, method, json}): Promise =>
      axios({
        method,
        url,
        data: json.events.map(e => {
          const {event, level, payload} = e;
          const {timestamp, data, user} = payload;
          return {
            event,
            level,
            ts: timestamp / 1000,
            data,
github paypal / paypal-checkout-components / src / external / pptm.js View on Github external
}).catch(err => {
        info('pptm_script_error', { error: stringifyError(err) });
    });
}