项目作者: matanlurey

项目描述 :
Cable for Stackdriver (Google Cloud Logging)
高级语言: Dart
项目地址: git://github.com/matanlurey/cable-stackdriver.git
创建时间: 2017-10-21T02:41:51Z
项目社区:https://github.com/matanlurey/cable-stackdriver

开源协议:BSD 3-Clause "New" or "Revised" License

下载


cable_stackdriver



Build Status


Pub Package Version


Latest Dartdocs

A Google Stackdriver logging plugin for the cable logging framework.

Installation

Add cable_stackdriver in your [pubspec.yaml][pubspec] file:

  1. dependencies:
  2. cable_stackdriver: ^0.1.0

And that’s it! See usage for details.

Usage

You can use Stackdriver on the server with a Google Cloud service account.

Once you have a <key>.json file, with the scope

  • https://www.googleapis.com/auth/logging.write

…you can create a Stackdriver object:

  1. import 'dart:async';
  2. import 'package:cable_stackdriver/cable_stackdriver.dart';
  3. Future<Null> main() async {
  4. final jsonConfig = loadJsonFile();
  5. final stackdriver = await Stackdriver.serviceAccount<String>(
  6. jsonConfig,
  7. logName: 'projects/${jsonConfig['project_id']}/logs/example',
  8. );
  9. final logger = new Logger(
  10. destinations: [
  11. // Also write to console.
  12. stackdriver,
  13. ],
  14. );
  15. // You can now use the logger.
  16. logger.log('Hello World', severity: Severity.warning);
  17. // Wait until there are no more pending messages being written.
  18. await stackdriver.onIdle;
  19. logger.close();
  20. }

Contributing

We welcome a diverse set of contributions, including, but not limited to:

For the stability of the API and existing users, consider opening an issue
first before implementing a large new feature or breaking an API. For smaller
changes (like documentation, minor bug fixes), just send a pull request.

Testing

All pull requests are validated against travis, and must pass.

Ensure code passes all our analyzer checks:

  1. $ dartanalyzer .

Ensure all code is formatted with the latest dev-channel SDK.

  1. $ dartfmt -w .

Run all of our unit tests (IN PROGRESS):

  1. $ pub run test