0.1.9 • Published 2 years ago

headless-manager-client v0.1.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Headless Manager Client

Installation

Using Yarn

yarn add headless-manager-client

Or NPM

npm install headless-manager-client

Usage

  1. Create the logger
// src/util/logger.ts
import Logger from 'headless-manager-client';
import axios from 'axios';

const logger = new Logger({
  appId: process.env.HM_APP_ID,
  apiUrl: process.env.HM_API_URL,
  submitEnabled: process.env.NODE_ENV !== 'development',
  // when using server side, also include a fetch client, e.g. node-fetch or axios
  fetchInstance: axios,
});

export default logger;
  1. Start logging
// src/lib/funcName.ts
import logger from '../util/logger';

const myAsyncFunc = async () => {
  logger.info('myAsyncFunc', 'Starting some async stuff');
  try {
    // some async logic
    logger.http('myAsyncFunc', 'Successfully did some logic');
  } catch (e) {
    logger.error('myAsyncFunc', 'Failed the async logic!', e);
  }
}

Log levels

  • error
  • warn
  • info
  • http
  • verbose
  • debug
  • silly
0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago