katana_logger 1.2.6 copy "katana_logger: ^1.2.6" to clipboard
katana_logger: ^1.2.6 copied to clipboard

unlisted

Base package for logging app performance and access status. Additional packages can be installed to use Firebase Analytics, etc.

Masamune logo

Katana Logger

Follow on Twitter Maintained with Melos


[YouTube] | [Packages] | [Twitter] | [LinkedIn]


Provides the ability to collect application logs for Katana/Masamune Framework.

Installation #

Import the following packages.

flutter pub add katana_logger

Implementation #

Advance preparation #

Be sure to place the LoggerAdapterScope widget near the root of the app.

Pass a LoggerAdapter such as RuntimeLoggerAdapter as the adapter parameter.

// main.dart
import 'package:flutter/material.dart';
import 'package:katana_logger/katana_logger.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return LoggerAdapterScope(
      adapter: const RuntimeLoggerAdapter(),
      child: MaterialApp(
        home: const LoggerPage(),
        title: "Flutter Demo",
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
      ),
    );
  }
}

Creating Logger Objects #

To perform logging, first create a Logger and keep it somewhere.

This Logger object actively performs the following logging

  • sendsendRawData:Records log events.
  • trace:Records trace events.

Since Logger inherits from ChangeNotifier, it is possible to monitor updates by using addListener, riverpod's ChangeNotifierProvider, etc.

It is also possible to check the logs recorded with the logList method.

// logger_page.dart
import 'package:flutter/material.dart';
import 'package:katana_logger/katana_logger.dart';

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

  @override
  State<StatefulWidget> createState() => LoggerPageState();
}

class LoggerPageState extends State<LoggerPage> {
  final logger = Logger();
  List<LogValue> _values = [];

  @override
  void initState() {
    super.initState();
    logger.addListener(_handledOnUpdate);
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    _handledOnUpdate();
  }

  Future<void> _handledOnUpdate() async {
    _values = await logger.logList();
    setState(() {});
  }

  @override
  void dispose() {
    super.dispose();
    logger.removeListener(_handledOnUpdate);
    logger.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("App Demo")),
      body: ListView(
        children: [
          ..._values.map(
            (e) => ListTile(
              title: Text(e.name),
              subtitle: Text(e.dateTime.toIso8601String()),
            ),
          )
        ],
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          logger.sendRawData("test", parameters: {"count": 5});
        },
        child: const Icon(Icons.add),
      ),
    );
  }
}
0
likes
0
pub points
7%
popularity

Publisher

verified publishermathru.net

Base package for logging app performance and access status. Additional packages can be installed to use Firebase Analytics, etc.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, katana, path_provider, shared_preferences

More

Packages that depend on katana_logger