critical_log 0.0.11 critical_log: ^0.0.11 copied to clipboard
A structured logging package for Dart and Flutter with support for critical and batch logging.
import 'package:flutter/material.dart';
import 'package:critical_log/log.dart';
late LogProvider? logProvider;
Future<void> main() async {
logProvider = LogProvider();
await logProvider?.init(
secret: 'your-secret',
platformName: 'test-platform',
baseUrl: 'https://api.test.com',
);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
final Logger logger =Logger(logService: LogService(logProvider!), logCount: 3);
MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Log Example')),
body: Center(
child: ElevatedButton(
onPressed: () {
logger.log(
title: 'Test Log',
message: 'This is a test log message.',
level: LogLevel.info,
enviroment: 'development',
);
},
child: const Text('Log Message'),
),
),
),
);
}
}