1.0.0 • Published 4 years ago
@botlogger/sdk v1.0.0
@botlogger/sdk
This is the official SDK for BotLogger.
Setting up the SDK
These are the options that you will need to provide when constructing the BotLogger SDK client:
| Name | Type | Required | Description | Default |
|---|---|---|---|---|
| apiVersions | object | Specifies the API versions to use for various endpoints. You usually do not need to manually provide this. | Check this section | |
| axios | object | A custom Axios instance | The default Axios instance | |
| endpoint | string | The base BotLogger service endpoint | https://api.bot-logger.com | |
| token | string | Yes | The application binding token acquired via the binding process |
// CJS
const { default: BotLoggerSDK } = require("@botlogger/sdk");
// ESM
import BotLoggerSDK from "@botlogger/sdk";
const botloggerSDK = new BotLoggerSDK({
token: "<your-token>",
});
// Here, you can either trigger the log-sending using sendLogs
await botloggerSDK.sendLogs({ message: "This is a log" });
// Or you can create a Writable stream and integrate it with your existing
// logging setup
const botloggerStream = botloggerSDK.asWritableStream();
const pinoLogger = pino(botloggerStream);
const winstonLogger = winston.createLogger({
format: winston.format.json(),
level: "info",
transports: [new winston.transports.Stream({ stream: botloggerStream })],
});apiVersions option
These are the properties supported by the apiVersions option.
| Name | Description | Default |
|---|---|---|
| sendLog | The main log ingestion endpoint | v1 |