relogs-io-js v0.1.5
relogs-io-js
NPM package for Relogs.io
Usage
If you don't have a Relogs workspace, go create one (30 seconds, free): app.relogs.io
Note your
workspace idandAPI key(See here on how to get them)Install the package
npm install relogs-io-jsInitialize the library
import {Relogs} from 'relogs-io-js'; const relogs = new Relogs({ workspaceId: "<your workspace id>", apiKey: "<your API key>", defaultTable: 'demo-ingest-from-js', ingestConsoleLogs: true, // if true, will upload console logs to Relogs suppressConsoleLogsToConsole: true // if true, will also suppress logs to console })Upload logs
console.info("TEST this will be logged as info"); console.warn("TEST this will be logged as warning"); console.error("TEST this will be logged as error"); console.log("TEST parameters will also be logged", { hello: "world" } { anotherParam: 1 }); await relogs.flushAsync(); // Can call flush to upload the logs (log are flushed every second by default) relogs.track({ myEvent: "You can log anything you want", moreData: 1234 }, "customTableName"); await relogs.end(); // Flush and stop logging (will wait for logs t upload for up to 10 seconds) console.log(`This log will not be uploaded to Relogs`);
Development
Install dependencies
npm installRun build. This will generate the compiled code with type definitions in the
distfolder.npm run buildFormatting and linting.
npm run lint npm run formatRun tests
npm test
Publish package
If you don't have an npm account, create one on: https://www.npmjs.com/signup or run the command:
npm adduserIf you already have an account, login by running the following command:
npm loginWhen you're successfully logged-in. Publish the package:
npm publishYou should now be able to
npm installyour published package. There is an npm package called reference-package which is generated from this cookiecutter. There is a sample usage in example/index.js.
Credits
This repo was bootstrapped by following this tutorial.
