pd_log 0.12.0 copy "pd_log: ^0.12.0" to clipboard
pd_log: ^0.12.0 copied to clipboard

Cross-platform Flutter logging with pure Dart; buffered file writes; no platform channels.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:pd_log/pd_log.dart';

import 'routes.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    PDLog.configureWith(
      consoleConfig: const ConsoleConfig(
        enabled: true,
        minLevel: LogLevel.verbose,
        theme: LogTheme.dark,
        showCaller: true,
        showTimestamp: true,
        defaultTag: 'PDLog',
      ),
      fileConfig: FileConfig(
        enabled: true,
        minLevel: LogLevel.verbose,
        logFormat: LogFormat.ecs,
        flushIntervalMs: 2000,
        maxBufferEntries: 100,
        maxBufferBytes: 65536,
        maskingConfig: LogMaskingConfig(
          enabled: true,
          defaultStrategy: MaskStrategy.full,
          maskChar: '*',
          maxMaskLength: 20,
          rules: [
            const FieldMaskRule(fieldNames: ['password', 'token', 'secret']),
            RegexMaskRule(pattern: RegExp(r'1[3-9]\d{9}')),
            RegexMaskRule(pattern: RegExp(r'[\w.-]+@[\w.-]+\.\w+')),
          ],
        ),
        showViewer: true,
        enableStackTrace: true,
        stackTraceLevels: {
          LogLevel.error,
          LogLevel.warn,
        },
      ),
    );
    PDLog.i('PDLog Example App starting...');
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'PDLog 演示应用',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        useMaterial3: true,
      ),
      initialRoute: Routes.home,
      routes: Routes.routes,
    );
  }
}
3
likes
150
points
106
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Cross-platform Flutter logging with pure Dart; buffered file writes; no platform channels.

Homepage
Repository

License

MIT (license)

Dependencies

flutter, path, path_provider, stack_trace

More

Packages that depend on pd_log