-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/aligorithm/logdna_flutter
- Loading branch information
Showing
1 changed file
with
74 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,80 @@ | ||
# logdna | ||
|
||
A new Flutter package project. | ||
A simple logdna client for Flutter. Logging made easy. | ||
|
||
[LogDNA](https://logdna.com) 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 | ||
|
||
This project is a starting point for a Dart | ||
[package](https://flutter.dev/developing-packages/), | ||
a library module containing code that can be shared easily across | ||
multiple Flutter or Dart projects. | ||
To get started, create an account on [logdna.com](https://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 | ||
|
||
```yaml | ||
dependencies: | ||
logdna: ^0.0.1 | ||
``` | ||
Run `flutter pub get` | ||
|
||
|
||
## Usage | ||
|
||
Import the package to your Dart code | ||
|
||
```dart | ||
import 'package:logdna/logdna.dart'; | ||
``` | ||
|
||
|
||
Instantiate the LogDna object | ||
|
||
```dart | ||
logDna = LogDNA( | ||
apiKey: "YOUR_API_KEY", | ||
appName: "APP_NAME", | ||
hostName: "HOSTNAME"); | ||
``` | ||
|
||
|
||
Add logs using the logDna object. | ||
|
||
```dart | ||
logDna.log(DnaLine( | ||
timestamp: DateTime.now().toUtc().millisecondsSinceEpoch.toString(), | ||
line: "event happened", | ||
level: DnaLevel.debug, | ||
env: DnaEnv.production, | ||
meta: { | ||
"custom field":"custom value", | ||
"custom field 2": "custom value 2" | ||
} | ||
)); | ||
``` | ||
|
||
|
||
Alternatively, you can create the log line separately and pass it into the log method. | ||
|
||
```dart | ||
line = DnaLine( | ||
timestamp: DateTime.now().toUtc().millisecondsSinceEpoch.toString(), | ||
line: "event happened", | ||
level: DnaLevel.debug, | ||
env: DnaEnv.production, | ||
meta: { | ||
"custom field":"custom value", | ||
"custom field 2": "custom value 2" | ||
} | ||
); | ||
``` | ||
|
||
You can add custom values after creating the 'DnaLine' instance. | ||
|
||
```dart | ||
line.addCustomField(CustomField(name:"custom name", value: "Custom value")); | ||
``` | ||
|
||
|
||
For help getting started with Flutter, view our | ||
[online documentation](https://flutter.dev/docs), which offers tutorials, | ||
samples, guidance on mobile development, and a full API reference. | ||
You've pushed your log to LogDNA! Check your LogDNA dashboard. Your new log line should appear. |