项目作者: aligorithm

项目描述 :
A simple LogDNA client for Flutter. Logging made easy.
高级语言: Dart
项目地址: git://github.com/aligorithm/logdna_flutter.git
创建时间: 2020-11-02T05:04:57Z
项目社区:https://github.com/aligorithm/logdna_flutter

开源协议:MIT License

下载


logdna

A simple logdna client for Flutter. Logging made easy.

LogDNA is a log management platform that integrates with many platforms. All logs are accessible in a centralized dashboard with features such as analysis, monitoring, filters and alerts.

Getting Started

To get started, create an account on logdna.com and get your ingestion API key. The set up process is straightforward. Here’s a link to the quickstart guide (https://docs.logdna.com/docs/logdna-quick-start-guide).

Installing the package

Add this to your project’s pubspec.yaml file

  1. dependencies:
  2. logdna: ^1.1.2

Run flutter pub get

Usage

Import the package to your Dart code

  1. import 'package:logdna/logdna.dart';

Instantiate the LogDna object

  1. logDna = LogDNA(
  2. apiKey: "YOUR_API_KEY",
  3. hostName: "HOSTNAME");

Add logs using the logDna object.

  1. logDna.log(DnaLine(
  2. timestamp: DateTime.now().toUtc().millisecondsSinceEpoch.toString(),
  3. line: "event happened",
  4. level: DnaLevel.debug,
  5. app "APP NAME"
  6. env: DnaEnv.production,
  7. meta: {
  8. "custom field":"custom value",
  9. "custom field 2": "custom value 2"
  10. }
  11. ));

Alternatively, you can create the log line separately and pass it into the log method.

  1. line = DnaLine(
  2. timestamp: DateTime.now().toUtc().millisecondsSinceEpoch.toString(),
  3. line: "event happened",
  4. level: DnaLevel.debug,
  5. app: "APP NAME"
  6. env: DnaEnv.production,
  7. meta: {
  8. "custom field":"custom value",
  9. "custom field 2": "custom value 2"
  10. }
  11. );

You can add custom values after creating the ‘DnaLine’ instance.

  1. line.addCustomField(CustomField(name:"custom name", value: "Custom value"));

You’ve pushed your log to LogDNA! Check your LogDNA dashboard. Your new log line should appear.