@palletech/pt-package-log-js

1.6.0 • Public • Published

PT Package Log

  • Posts logs to the relevant API endpoint based on the stage

Sample usage

process.env.PT_LOGGER_API_KEY = 'REDACTED';
process.env.STAGE = 'test';
const { Logger } = require('@palletech/pt-package-log-js');

const main = async() => {
    await Logger.info({
        title: 'test info',
        message: 'there is a message2',
        type: 'someType',
        code: 12,
        tags: ['test', 'josh'],
        stackTrace: 'nothing in the stack'
    });
    console.log('info posted')
}
main();

Getting Started

  • This project contains a hard-coded raw_log_pb.js file --> make sure this is kept up to date
  • The file is embedded in this project so that this package can safely be listed publicl without other PT proto dependencies

Prerequisites

Installing

  • Run make install to install node_modules

Running the tests

This project uses mocha

  • Invoke tests with make test
  • They will be run automatically as pre-push hook through Husky
  • You can use make cover to check your code coverage

Integration tests locally

If you run pt-be-daatstore-ingress locally (yarn run devOffline) and use the example script above you can ensure that the post request comes through to the local Lambda as expected.

This is because the TEST environment is configured to use http://localhost:3000 as its POST url (which is the same URL used by serverless offline)

Coding style

This project enforces the Airbnb Javascript Style Guide

  • Exceptions and modifications are shown in .eslintrc.js
  • Linting and editor configuration is handled automatically through .editorconfig, .eslintrc.js and prettier.config.js
  • Before committing your code, you should run yarn prettier to cleanup your code (although some linting will still be enforced on git commit)

Deployment

  • npm publish --access public

Readme

Keywords

none

Package Sidebar

Install

npm i @palletech/pt-package-log-js

Weekly Downloads

0

Version

1.6.0

License

SEE LICENSE IN LICENSE.md

Unpacked Size

24.3 kB

Total Files

13

Last publish

Collaborators

  • anwain
  • joshpt
  • ptbuilder