google_cloud_logging 0.5.0 copy "google_cloud_logging: ^0.5.0" to clipboard
google_cloud_logging: ^0.5.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.

Features #

  • Google Cloud Structured Logging: Utilities to construct log entries that seamlessly map to Google Cloud's native structured logging schema on stdout.
  • CloudLogger: An extensible base logging class with convenience methods for standard Google Cloud logging severities (debug, info, notice, warning, error, etc.).
  • Safe Sanitization: Deep primitive checking to format complex object payloads, preventing cyclic referencing and providing graceful string fallback.

Usage #

Structured Logging on stdout #

import 'package:google_cloud_logging/google_cloud_logging.dart';

void main() {
  // Create a simple structured log string
  final logString = createStructuredLog(
    'An informative event happened.',
    LogSeverity.info,
    payload: {'event_id': 123, 'status': 'success'},
  );

  // Print the formatted JSON directly to stdout
  print(logString);
}

Using the CloudLogger #

import 'package:google_cloud_logging/google_cloud_logging.dart';

const _logger = CloudLogger.printLogger();

void main() {
  _logger.info('Processing item.', payload: {'itemId': 'A-987'});
  try {
    throw Exception('Failed to connect to DB');
  } catch (error, stack) {
    _logger.error('Database connection failure - $error', stackTrace: stack);
  }
}
0
likes
150
points
156
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, google_cloud_protobuf, meta, stack_trace

More

Packages that depend on google_cloud_logging