1.0.3 • Published 5 months ago

log-to-api v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

LogToApi

This is a package that helps you send logs from your application to an API server.

The application can be used from any platform (Vanilla Js, React Js, Vue Js, Angular etc) all you need to do is to provide and endpoint that accept POST api connection

How to use this package

  1. Install the log-to-api package

    using NPM

    npm install log-to-api

    using yarn

    yarn add log-to-api
  2. Import the log-to-api package

    import LogToApi from "log-to-api";
  3. Initiate an instance of the log-to-api class using the following:

  • url - (required) eg: https://some-api.com/path
  • httpHeaders - (optional) eg { 'X-Custom-Header': 'value' }
  • defaultMeta - (optional) eg: { app: 'testApp' }

    const url = "https://some-api.com/path";
    const httpHeaders = { 
      'X-Custom-Header': 'value' 
    };
    const defaultMeta = {
      app: 'testApp'
    }
    
    const logToApiOptions = {
      url, 
      httpHeaders,
      defaultMeta
    }
      
    const logToApi = new LogToApi(logToApiOptions);
  1. Send your logs to the backend using any of the following methods:

    await logToApi.debug('Test debug message');
    await logToApi.info('Test info message');
    await logToApi.warning('Test warning message');
    await logToApi.error('Test error message');
    await logToApi.critical('Test critical message');
1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago