项目作者: coralogix

项目描述 :
Coralogix NodeJS SDK
高级语言: TypeScript
项目地址: git://github.com/coralogix/nodejs-coralogix-sdk.git
创建时间: 2018-07-07T11:38:44Z
项目社区:https://github.com/coralogix/nodejs-coralogix-sdk

开源协议:Apache License 2.0

下载


Coralogix Node.js SDK

npm
license
node
npm
Build Status
codecov
Maintainability
Test Coverage
GitHub issues
GitHub pull requests
GitHub contributors


Use coralogix-logger to easily send your logs to Coralogix’s log analytics platform.

Table of Content

Prerequisites

Before beginning you must have installed:

  • Node.js
  • npm

Installation

  1. npm install --save coralogix-logger

Usage

JavaScript

  1. var Coralogix = require("coralogix-logger");
  2. // global confing for application name, private key, subsystem name
  3. const config = new Coralogix.LoggerConfig({
  4. applicationName: "node tester",
  5. privateKey: "YOUR_PRIVATE_KEY",
  6. subsystemName: "node tester sub",
  7. });
  8. Coralogix.CoralogixLogger.configure(config);
  9. // create a new logger with category
  10. const logger = new Coralogix.CoralogixLogger("My Category");
  11. // create a log
  12. const log = new Coralogix.Log({
  13. severity: Coralogix.Severity.info,
  14. className: "className",
  15. methodName: "methodName",
  16. text: "log data",
  17. })
  18. // send log to coralogix
  19. logger.addLog(log);

TypeScript

For using TypeScript sources you should clone this repository, because
it’s not included in npm distribution.

  1. import {Log, Severity, CoralogixLogger, LoggerConfig} from "coralogix-logger";
  2. // global confing for application name, private key, subsystem name
  3. const config = new LoggerConfig({
  4. applicationName: "node tester",
  5. privateKey: "YOUR_PRIVATE_KEY",
  6. subsystemName: "node tester sub",
  7. });
  8. CoralogixLogger.configure(config);
  9. // create a new logger with category
  10. logger: CoralogixLogger = new CoralogixLogger("My Category")
  11. // create a log
  12. const log = new Log({
  13. severity: Severity.info,
  14. className: "className",
  15. methodName: "methodName",
  16. text: "log data",
  17. })
  18. // send log to coralogix
  19. logger.addLog(log);