live_log_care 2.1.0 copy "live_log_care: ^2.1.0" to clipboard
live_log_care: ^2.1.0 copied to clipboard

Redaction-safe logging for Flutter: build-mode gated (silent in release) and auto-scrubs passwords, tokens, cookies, OTPs and PII from logs, Dio and Bloc.

example/lib/main.dart

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:live_log_care/live_log_care.dart';

void main() {
  // 1) Configure once (optional — secure defaults apply without this).
  //    `.clean()` gives prefix-free, indented-JSON output (great for the
  //    VS Code Debug Console). Drop it for the default boxed PrettyPrinter.
  LiveLog.configure(LiveLogConfig.clean(releaseLevel: LogLevel.error));

  // 2) Teach the redactor about app-specific secrets.
  LogRedactor.addSensitiveKeys(['iban', 'card_holder']);

  // 3) Route Bloc/Cubit events through LiveLog.
  Bloc.observer = LiveLogBlocObserver();

  // 4) Use a redaction-safe Dio logger instead of a raw one.
  //    `prettyJson: true` renders request/response bodies as indented JSON.
  final dio =
      Dio()..interceptors.add(RedactingDioInterceptor(prettyJson: true));

  LiveLog.i('app started');
  // The password is masked automatically:
  LiveLog.d({'login': 'user@example.com', 'password': 'hunter2'});

  runApp(ExampleApp(dio: dio));
}

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key, required this.dio});

  final Dio dio;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'live_log_care',
      home: Scaffold(
        appBar: AppBar(title: const Text('live_log_care')),
        body: Center(
          child: ElevatedButton(
            onPressed: () {
              try {
                throw StateError('boom');
              } catch (e, s) {
                LiveLog.e('button tap failed', error: e, stackTrace: s);
              }
            },
            child: const Text('Log a redacted error'),
          ),
        ),
      ),
    );
  }
}
1
likes
0
points
313
downloads

Publisher

unverified uploader

Weekly Downloads

Redaction-safe logging for Flutter: build-mode gated (silent in release) and auto-scrubs passwords, tokens, cookies, OTPs and PII from logs, Dio and Bloc.

Repository (GitHub)
View/report issues

Topics

#logging #security #redaction #dio

License

unknown (license)

Dependencies

dio, flutter, flutter_bloc

More

Packages that depend on live_log_care