logz 0.0.2 copy "logz: ^0.0.2" to clipboard
logz: ^0.0.2 copied to clipboard

A lightweight, easy-to-use structured logging package for Dart and Flutter.

example/lib/main.dart

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

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'LogZ',
      theme: ThemeData(colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple)),
      home: const MyHomePage(title: 'LogZ'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  final logZ = LogZ(zipPassword: '123456', logFilePrefix: 'example', printLogs: true);

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
    logZ.logToFile('Logging via logToFile function: $_counter');
    if (_counter >= 10) {
      Future.delayed(const Duration(seconds: 1), () {
        setState(() {
          _counter = 0;
        });
        logZ.zipToShareLog();
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text(widget.title)),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text('Click the button to increment the counter:'),
            Text('$_counter', style: Theme.of(context).textTheme.headlineMedium),
            const Text('To write logs. Until 10 times, logs.zip file will be created.'),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(onPressed: _incrementCounter, tooltip: 'Increment', child: const Icon(Icons.add)),
    );
  }
}
0
likes
0
points
47
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight, easy-to-use structured logging package for Dart and Flutter.

License

unknown (license)

Dependencies

archive, device_info_plus, flutter, package_info_plus, path_provider, share_plus

More

Packages that depend on logz