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 id
andAPI key
(See here on how to get them)Install the package
npm install relogs-io-js
Initialize 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 install
Run build. This will generate the compiled code with type definitions in the
dist
folder.npm run build
Formatting and linting.
npm run lint npm run format
Run 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 adduser
If you already have an account, login by running the following command:
npm login
When you're successfully logged-in. Publish the package:
npm publish
You should now be able to
npm install
your 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.