flutter_logan_pro 1.0.1
flutter_logan_pro: ^1.0.1 copied to clipboard
A high-performance, robust log plugin for Flutter based on Meituan Logan. Fixed truncation and decryption issues.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_logan_pro/flutter_logan_pro.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
// Replace with your own 16-byte key and iv
final String _loganSecretKey = "";
final String _loganSecretIV = "";
@override
void initState() {
super.initState();
}
Future<void> _initLogan(BuildContext context) async {
try {
await FlutterLoganPro.init(
secretKey: _loganSecretKey,
secretIV: _loganSecretIV,
maxFileLen: 1024 * 1024 * 10,isDebug: true,maxReversedDate: 7);
_showSnackBar(context, 'Logan init success');
} on PlatformException catch (e) {
_showSnackBar(context, 'Logan init failed: ${e.message}');
}
}
Future<void> _addLog(BuildContext context) async {
try {
await FlutterLoganPro.log(
'This is a test log from flutter_logan plugin 啊打算离开打瞌睡打瞌睡打卡打卡时打卡打卡双卡双待卡开始打卡打卡扩大开始打卡打卡上课打卡打卡深刻的卡上的卡都是卡点卡上打卡上看到卡是短裤 at ${DateTime.now()}');
_showSnackBar(context, 'Log added');
} on PlatformException catch (e) {
_showSnackBar(context, 'Add log failed: ${e.message}');
}
}
void _showSnackBar(BuildContext context, String message) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(message)));
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Flutter Logan Plugin'),
),
body: Builder(
builder: (scaffoldContext) => Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () => _initLogan(scaffoldContext),
child: const Text('Init Logan'),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () => _addLog(scaffoldContext),
child: const Text('Add Log'),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: ()async {
var res = await FlutterLoganPro.send(url: "",appId: "123131");
print(res.statusCode);
},
child: const Text('Send Log'),
),
],
),
),
),
),
);
}
}