How to use @adobe/helix-log - 7 common examples

To help you get started, we’ve selected a few @adobe/helix-log 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 adobe / helix-pipeline / test / testFrontmatter.js View on Github external
const assert = require('assert');
const { cloneDeep } = require('lodash');
const yaml = require('js-yaml');
const { multiline } = require('@adobe/helix-shared').string;
const { SimpleInterface, ConsoleLogger } = require('@adobe/helix-log');
const {
  flattenTree, concat, each,
} = require('ferrum');
const parseMd = require('../src/html/parse-markdown');
const parseFront = require('../src/html/parse-frontmatter');

const { FrontmatterParsingError } = parseFront;

let warning;

const logger = new SimpleInterface({ logger: new ConsoleLogger() });

const procMd = (md) => {
  const dat = { content: { body: multiline(md) } };
  parseMd(dat, { logger });
  const orig = cloneDeep(dat.content.mdast);
  parseFront(dat, { logger });
  return { orig, proc: dat.content.mdast };
};

const ck = (wat, md, ast) => {
  it(wat, () => {
    const { proc } = procMd(md);
    // Discard position info
    const nodes = flattenTree(proc,
      (node, recurse) => concat([node], recurse(node.children || [])));
    each(nodes, (node) => {
github adobe / helix-pipeline / src / defaults / default.js View on Github external
function pipe(next, context, action) {
  const mypipeline = new Pipeline(action);
  mypipeline.use(next);
  return mypipeline.run(context);
}

/**
 *
 * @param {Function} cont the continuation function
 * @returns {Function} the wrapped main function
 */
const pre = (cont) => cont;

const log = new SimpleInterface({
  level: 'debug',
  logger: new ConsoleLogger(),
});
// keep backward compatible with winston logger
log.log = (level, ...msg) => log._logImpl(level, ...msg, {});

const defaults = {
  pipe,
  pre,
  log,
};

module.exports = defaults;
github adobe / helix-pipeline / src / defaults / default.js View on Github external
* @returns {Function} a function to execute.
 */
function pipe(next, context, action) {
  const mypipeline = new Pipeline(action);
  mypipeline.use(next);
  return mypipeline.run(context);
}

/**
 *
 * @param {Function} cont the continuation function
 * @returns {Function} the wrapped main function
 */
const pre = (cont) => cont;

const log = new SimpleInterface({
  level: 'debug',
  logger: new ConsoleLogger(),
});
// keep backward compatible with winston logger
log.log = (level, ...msg) => log._logImpl(level, ...msg, {});

const defaults = {
  pipe,
  pre,
  log,
};

module.exports = defaults;
github adobe / jsonschema2md / lib / markdownWriter.js View on Github external
function simpletype(prop) {
  const { type } = prop;
  if (prop.$ref !== undefined) {
    if (prop.$linkVal !== undefined) {
      prop.simpletype = prop.$linkVal;
    } else {
      info(`unresolved reference: ${prop.$ref}`);
      prop.simpletype = 'reference';
    }
  } else if (prop.enum !== undefined) {
    prop.simpletype = '`enum`';
    if (prop['meta:enum'] === undefined) {
      prop['meta:enum'] = {};
    }
    for (let i = 0; i < prop.enum.length; i += 1) {
      if (prop['meta:enum'][prop.enum[i]] === undefined) {
        //  setting an empty description for each unknown enum
        prop['meta:enum'][prop.enum[i]] = '';
      }
    }
  } else if (prop.const !== undefined) {
    prop.simpletype = '`const`';
  } else if (type === 'string') {
github adobe / helix-pipeline / test / testOpenwhisk.js View on Github external
it('it logs even if no trace logging', async () => {
    const winstonLogger = new SimpleInterface({
      level: 'debug',
      logger: new ConsoleLogger(),
    });
    winstonLogger.trace = undefined;

    const params = {
      __ow_headers: {
        'content-type': 'application/json',
      },
      __ow_method: 'get',
      __ow_logger: winstonLogger,
    };

    const ret = await runPipeline((context, action) => {
      action.logger.trace({ myId: 42 }, 'Hello, world');
    }, pipe, params);

    assert.deepEqual(ret, {
github adobe / helix-pipeline / test / testOpenwhisk.js View on Github external
it('it logs even if no trace logging', async () => {
    const winstonLogger = new SimpleInterface({
      level: 'debug',
      logger: new ConsoleLogger(),
    });
    winstonLogger.trace = undefined;

    const params = {
      __ow_headers: {
        'content-type': 'application/json',
      },
      __ow_method: 'get',
      __ow_logger: winstonLogger,
    };

    const ret = await runPipeline((context, action) => {
      action.logger.trace({ myId: 42 }, 'Hello, world');
    }, pipe, params);
github adobe / helix-pipeline / test / testOpenwhisk.js View on Github external
beforeEach(() => {
    nock.restore();
    nock.activate();
    nock.cleanAll();

    rootLogger.loggers.delete('OpenWhiskLogger');
  });

@adobe/helix-log

Logging for Helix

Apache-2.0
Latest version published 13 days ago

Package Health Score

84 / 100
Full package analysis

Similar packages