1.0.0 • Published 3 years ago

@botlogger/sdk v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

@botlogger/sdk

npm version

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:

NameTypeRequiredDescriptionDefault
apiVersionsobjectSpecifies the API versions to use for various endpoints. You usually do not need to manually provide this.Check this section
axiosobjectA custom Axios instanceThe default Axios instance
endpointstringThe base BotLogger service endpointhttps://api.bot-logger.com
tokenstringYesThe 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.

NameDescriptionDefault
sendLogThe main log ingestion endpointv1