FLog는 지속적인 저장을 지원하는 빠르고 간단한 로깅을 가능하게 하는 가벼운 플러터 로깅 패키지입니다. 모든 로그 항목은 로컬 데이터베이스에 저장되어 개발자가 디버깅을 위해 로그를 검토하고 파일로 내보낼 수 있습니다. 사용하기 쉬운 설계로 Android, iOS, macOS, Windows, Linux 등 다양한 플랫폼의 앱에 원활하게 통합됩니다. 구조화된 로깅을 지원하며 개발 및 테스트 중 앱 동작을 추적할 수 있는 간편한 방법을 제공합니다.
사용 사례
실시간으로 앱 문제 디버깅
사용자 보고 오류 검토
시간이 지남에 따라 앱 성능 분석
팀 협업을 위한 로그 내보내기
개발 중 애플리케이션 흐름 추적
주요 기능
로컬 DB에서의 지속적인 로그 저장
로그를 파일로 쉽게 내보내기
크로스 플랫폼 지원
간단한 API 통합
실시간 로그 보기
최소한의 설정 필요
적합한 대상
기본 로깅을 원하는 개발자
로그 내보내기 기능이 필요한 팀
오프라인 로그 보유가 필요한 앱
프로토타이핑 및 테스트 단계
모바일 및 데스크톱 애플리케이션
고려 사항
로컬에 저장된 로그는 장치 스토리지 사용량을 증가시킬 수 있습니다
생산용 모니터링을 위한 것이 아님
데이터베이스 크기는 사전에 관리되어야 합니다
내장된 로그 필터링 또는 검색 없음
로컬 데이터 지속성만 제한
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
FLogs Advance Logging Framework
FLog is an Advanced Logging Framework develop in flutter that provides quick & simple logging solution. All logs are saved to the DB which can then be exported as a zip file.
Overview
FLogs is written in dart. It basically features two types of loggers (FLog & DataLog) with many of advanced features needed for logging. Logs are saved in database which can then be exported in document directory of Android|iOS device. The logs are helpful when developer wants to analyze user activities within the app. These logs can be filtered and sorted easily. Logs can easily be exported as zip file base on filter type, the zip file can then be uploaded to server or to use it locally.
Many times we want to log set of data to analyze certain activity e.g. Location (GPS Coordinates), Device info, Network requests etc. this helps us to quickly identify and fix the issue that is hard to debug when the app is in production. FLogs provide such functionality to log data set into database. These logs can then be fetched by applying different convinience filters availale.
Features
Logs events in files created separately every hour with 'FLogs' logger. (24 hours)
Files can be compressed and exported for time and day filters
Clear Logs easily
Save logs to custom path (Supported in Android only)
Export Logs to custom path as zip file (Supported in Android only)
Custom Log formatting
CSV support
Custom timestamps support
Custom data logging support with 'DataLogs' logger.
Encryption support added
Multiple directory structures
Print logs as String
Export all or single types of logs
Advanced Automation for deleting logs automatically
Exports HTML formatted exceptions
Log level support
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:f_logs:^1.0.x
2. Install it
You can install packages from the command line:
with Flutter
$ flutter packages get
Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import'package:f_logs/f_logs.dart';
How to use
Log files are exported on storage directory so it's very important to add these permissions to your project's manifest file first.
<key>NSPhotoLibraryAddUsageDescription</key>
<string>FLogs would like to save photos from the app to your gallery</string><key>NSPhotoLibraryUsageDescription</key><string>FLogs would like to access your photo gallery for uploading images to the app</string>
To save logs, simply call any of the method mentioned below:
1. Simple Trace Log
FLog.trace(
className: "HomePage",
methodName: "_buildRow1",
text: "My log");
2. Simple Debug Log
FLog.debug(
className: "HomePage",
methodName: "_buildRow1",
text: "My log");
3. Simple Info Log
FLog.info(
className: "HomePage",
methodName: "_buildRow1",
text: "My log");
4. Simple Warning Log
FLog.warning(
className: "HomePage",
methodName: "_buildRow1",
text: "My log";
5. Simple Error Log
FLog.error(
className: "HomePage",
methodName: "_buildRow1",
text: "My log");
6. Simple Severe Log
FLog.severe(
className: "HomePage",
methodName: "_buildRow1",
text: "My log");
7. Severe Log with Exception and StackTrace
FLog.logThis(
className: "HomePage",
methodName: "_buildRow1",
text: "My log",
type: LogLevel.SEVERE,
exception: Exception("This is an Exception!"),
stacktrace: StackTrace.current);
8. Simple Fatal Log
FLog.fatal(
className: "HomePage",
methodName: "_buildRow1",
text: "My log");
FLogs provide many convenience methods to save logs into or to fetch them from database, below is the list of all the methods available:
1. logThis
Logs string data along with className, methodName, logText and the type of log (LogLevel.SEVERE, LogLevel.INFO) etc. The same method can be used to log exception(s) or data logs. The difference between FLog and DataLogs is described above, you can also check out wiki for more details. If either className or methodName is not provided, it will automatically be taken by getting calling class and method.
staticlogThis({
String className, // This is optional if not provided, then it will automatically be taken by getting calling classString methodName, // This is optional if not provided, then it will automatically be taken by getting calling method@requiredString text,
@requiredLogLevel type,
Exception exception,
String dataLogType,
StackTrace stacktrace,
}){}
2. trace
Logs string data along with className, methodName, logText and the type of log (LogLevel.SEVERE, LogLevel.INFO) etc. The same method can be used to log exception(s) or data logs. If either className or methodName is not provided, it will automatically be taken by getting calling class and method.
statictrace({
String className, // This is optional if not provided, then it will automatically be taken by getting calling classString methodName, // This is optional if not provided, then it will automatically be taken by getting calling method@requiredString text,
Exception exception,
String dataLogType,
StackTrace stacktrace,
}){}
3. debug
Logs string data along with className, methodName, logText and the type of log (LogLevel.SEVERE, LogLevel.INFO) etc. The same method can be used to log exception(s) or data logs. If either className or methodName is not provided, it will automatically be taken by getting calling class and method.
staticdebug({
String className, // This is optional if not provided, then it will automatically be taken by getting calling classString methodName, // This is optional if not provided, then it will automatically be taken by getting calling method@requiredString text,
Exception exception,
String dataLogType,
StackTrace stacktrace,
}){}
4. info
Logs string data along with className, methodName, logText and the type of log (LogLevel.SEVERE, LogLevel.INFO) etc. The same method can be used to log exception(s) or data logs. If either className or methodName is not provided, it will automatically be taken by getting calling class and method.
staticinfo({
String className, // This is optional if not provided, then it will automatically be taken by getting calling classString methodName, // This is optional if not provided, then it will automatically be taken by getting calling method@requiredString text,
Exception exception,
String dataLogType,
StackTrace stacktrace,
}){}
5. warning
Logs string data along with className, methodName, logText and the type of log (LogLevel.SEVERE, LogLevel.INFO) etc. The same method can be used to log exception(s) or data logs. If either className or methodName is not provided, it will automatically be taken by getting calling class and method.
staticwarning({
String className, // This is optional if not provided, then it will automatically be taken by getting calling classString methodName, // This is optional if not provided, then it will automatically be taken by getting calling method@requiredString text,
Exception exception,
String dataLogType,
StackTrace stacktrace,
}){}
6. error
Logs string data along with className, methodName, logText and the type of log (LogLevel.SEVERE, LogLevel.INFO) etc. The same method can be used to log exception(s) or data logs. If either className or methodName is not provided, it will automatically be taken by getting calling class and method.
staticerror({
String className, // This is optional if not provided, then it will automatically be taken by getting calling classString methodName, // This is optional if not provided, then it will automatically be taken by getting calling method@requiredString text,
Exception exception,
String dataLogType,
StackTrace stacktrace,
}){}
7. severe
Logs string data along with className, methodName, logText and the type of log (LogLevel.SEVERE, LogLevel.INFO) etc. The same method can be used to log exception(s) or data logs. If either className or methodName is not provided, it will automatically be taken by getting calling class and method.
staticsevere({
String className, // This is optional if not provided, then it will automatically be taken by getting calling classString methodName, // This is optional if not provided, then it will automatically be taken by getting calling method@requiredString text,
Exception exception,
String dataLogType,
StackTrace stacktrace,
}){}
8. fatal
Logs string data along with className, methodName, logText and the type of log (LogLevel.SEVERE, LogLevel.INFO) etc. The same method can be used to log exception(s) or data logs. If either className or methodName is not provided, it will automatically be taken by getting calling class and method.
staticfatal({
String className, // This is optional if not provided, then it will automatically be taken by getting calling classString methodName, // This is optional if not provided, then it will automatically be taken by getting calling method@requiredString text,
Exception exception,
String dataLogType,
StackTrace stacktrace,
}){}
9. printLogs
Fetches all the logs from database and prints them as a string using StringBuffer()
staticprintLogs() async {}
10. getAllLogsByCustomFilter
Accepts list of filters as an arguments and returns list of logs based on the provided filters. The use of Filters with their usage is explained in wiki, please checkout wiki for more details.
A convenience method that filters data based on the provided filter params e.g. dataLogsType (DataLogType.DEVICE, DataLogType.NETWORK), logLevels(LogLevel.SEVERE, LogLevel.INFO), startTimeInMillis (millisec of the day you from where you want logs to be fetched), endTimeInMillis (milisec of the day you till you want logs to be fetched) and filterType (FilterType.LAST_HOUR, FilterType.LAST_24_HOURS, FilterType.TODAY, FilterType.WEEK, FilterType.ALL). Filter type can't be used with startTimeInMillis, endTimeInMillis, if so the priority will be given to startTimeInMillis, endTimeInMillis. In-order to have full control over filters, use method provided above.
staticFuture<List<Log>> getAllLogsByFilter(
{List<String> dataLogsType,
List<String> logLevels,
int startTimeInMillis,
int endTimeInMillis,
FilterType filterType}}) async {}
12. getAllLogs
Fetches all the logs from database and returns a list of logs.
staticFuture<List<Log>> getAllLogs() async {}
13. exportLogs
Exports logs to external storage under FLog directory.
staticexportLogs() async {}
14. clearLogs
Clears all the logs stored in database.
staticclearLogs() {}
15. applyConfigurations
Apply user provided configurations to FLogs.
staticapplyConfigurations(LogsConfig config) {}
16. deleteAllLogsByFilter
Accepts list of filters as an arguments and delete logs based on the provided filters. The use of Filters with their usage is explained in wiki, please checkout wiki for more details.