logger_easier 0.0.3+1 copy "logger_easier: ^0.0.3+1" to clipboard
logger_easier: ^0.0.3+1 copied to clipboard

A modern logging management solution tailored specifically for Dart and Flutter applications. It provides a highly flexible and feature-rich logging system designed to simplify developers' log managem [...]

example/lib/main.dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'app/log_helper.dart';
import 'ui/home_page.dart';
import 'app/size_based_logger.dart';
// import 'app/time_based_logger.dart';  // 预留基于时间的配置

void main() async {
  runZonedGuarded(() async {
    WidgetsFlutterBinding.ensureInitialized();

    // 初始化基于大小的日志系统
    await SizeBasedLoggerConfig.instance.initialize();
    // 如果需要使用基于时间的日志系统,注释上面的行,取消注释下面的行
    // await TimeBasedLoggerConfig.instance.initialize();

    // 配置Flutter错误处理
    FlutterError.onError = (details) {
      FlutterError.presentError(details);
      Log.error('Flutter error',
          error: details.exception, stackTrace: details.stack);
    };

    Log.info('Application starting...');

    runApp(const LoggerDemoApp());
  }, (error, stack) {
    // 在日志系统初始化之前发生的错误,直接打印到控制台
    if (SizeBasedLoggerConfig.instance.isInitialized) {
      Log.critical('Uncaught error', error: error, stackTrace: stack);
    } else {
      print('Error before logger initialization: $error\n$stack');
    }
  });
}

class LoggerDemoApp extends StatelessWidget {
  const LoggerDemoApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Logger Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        useMaterial3: true,
      ),
      home: const HomePage(),
    );
  }
}
2
likes
115
points
7
downloads
screenshot

Publisher

verified publisherflutter-online.top

Weekly Downloads

A modern logging management solution tailored specifically for Dart and Flutter applications. It provides a highly flexible and feature-rich logging system designed to simplify developers' log management while offering significant customization capabilities.

Homepage
Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (license)

Dependencies

archive, crypto, encrypt, intl, path, stack_trace, synchronized, vm_service

More

Packages that depend on logger_easier