google_cloud_logging 0.6.0 copy "google_cloud_logging: ^0.6.0" to clipboard
google_cloud_logging: ^0.6.0 copied to clipboard

Structured logging for Google Cloud environments with trace correlation and automatic formatting.

Google Cloud Logging for Dart #

pub package package publisher

NOTE: This is a community-supported project, meaning there is no official level of support. The code is not covered by any SLA or deprecation policy.

Feel free to open issues for bugs and feature requests.

A lightweight logging package for creating formatted logs suitable for Google Cloud Platform, specifically tailored for Google Cloud structured logging.

Usage #

Using the StructuredLogger directly #

import 'package:google_cloud_logging/google_cloud_logging.dart';

const _logger = StructuredLogger();

void main() {
  _logger.info({'message': 'Processing item.', 'itemId': 'A-987'});
  try {
    throw Exception('Failed to connect to DB');
  } catch (error, stack) {
    _logger.error('Database connection failure - $error', stackTrace: stack);
  }
}

Using StructuredLogger with package:logging #

import 'package:google_cloud_logging/google_cloud_logging.dart';
import 'package:logging/logging.dart';

final _logger = Logger('my-service');

void main() {
  // Configure the standard logger with StructuredLogger.
  Logger.root.onRecord.listen(const StructuredLogger().handleLogRecord);
  Logger.root.level = Level.ALL;

  _logger.info('Processing item.', {'itemId': 'A-987'});
  try {
    throw Exception('Failed to connect to DB');
  } catch (error, stack) {
    _logger.severe('Database connection failure - $error', error, stack);
  }
}
0
likes
150
points
452
downloads

Documentation

API reference

Publisher

verified publisherlabs.dart.dev

Weekly Downloads

Structured logging for Google Cloud environments with trace correlation and automatic formatting.

Repository (GitHub)
View/report issues
Contributing

License

Apache-2.0 (license)

Dependencies

google_cloud_logging_type, google_cloud_logging_v2, logging, meta, stack_trace, web

More

Packages that depend on google_cloud_logging