omni_logger 2.0.0 copy "omni_logger: ^2.0.0" to clipboard
omni_logger: ^2.0.0 copied to clipboard

Omni Logger is a production-ready logging package for Flutter with auto-configuration, file rotation, isolate support, and build mode optimization.

example/lib/main.dart

import 'package:example/appLog/applog.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  if (kDebugMode) {
    print('Setup OmniLogger ...');
  }

  try {
    await AppLog.setup();
  } catch (e) {
    debugPrint('Outer AppLog setup emergency fallback: $e');
  }

  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'OmniLogger Example',
      debugShowCheckedModeBanner: false,
      home: const HomePage(),
    );
  }
}

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

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final log = AppLog.log('HomePage');
  int _counter = 0;

  void _increment() {
    setState(() => _counter++);
    log.i('Counter incremented to $_counter');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('OmniLogger Example')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              'Counter: $_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: _increment,
              child: const Text('Increment Counter'),
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    settings: const RouteSettings(name: '/second'),
                    builder: (context) => const SecondPage(),
                  ),
                );
                log.i('Navigating to SecondPage');
              },
              child: const Text('Navigate to Second Page'),
            ),
          ],
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Second Page')),
      body: const Center(child: Text('This is the second page')),
    );
  }
}
0
likes
160
points
306
downloads

Documentation

API reference

Publisher

verified publisherklexarolabs.com

Weekly Downloads

Omni Logger is a production-ready logging package for Flutter with auto-configuration, file rotation, isolate support, and build mode optimization.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

device_info_plus, flutter, logger, path, path_provider

More

Packages that depend on omni_logger