mirror of
				https://github.com/AppFlowy-IO/AppFlowy.git
				synced 2025-10-31 10:03:18 +00:00 
			
		
		
		
	 61fd608200
			
		
	
	
		61fd608200
		
			
		
	
	
	
	
		
			
			* refactor: rename structs * chore: read database id from view * chore: fix open database error because of create a database view for database id * chore: fix tests * chore: rename datbase id to view id in flutter * refactor: move grid and board to database view folder * refactor: rename functions * refactor: move calender to datbase view folder * refactor: rename app_flowy to appflowy_flutter * chore: reanming * chore: fix freeze gen * chore: remove todos * refactor: view process events * chore: add link database test * chore: just open view if there is opened database
		
			
				
	
	
		
			75 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			75 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| // ignore: import_of_legacy_library_into_null_safe
 | |
| import 'dart:ffi';
 | |
| 
 | |
| import 'package:flutter/foundation.dart';
 | |
| import 'package:logger/logger.dart';
 | |
| import 'package:ffi/ffi.dart' as ffi;
 | |
| import 'ffi.dart';
 | |
| 
 | |
| class Log {
 | |
|   static final shared = Log();
 | |
|   late Logger _logger;
 | |
| 
 | |
|   Log() {
 | |
|     _logger = Logger(
 | |
|       printer: PrettyPrinter(
 | |
|           methodCount: 2, // number of method calls to be displayed
 | |
|           errorMethodCount:
 | |
|               8, // number of method calls if stacktrace is provided
 | |
|           lineLength: 120, // width of the output
 | |
|           colors: true, // Colorful log messages
 | |
|           printEmojis: true, // Print an emoji for each log message
 | |
|           printTime: false // Should each log print contain a timestamp
 | |
|           ),
 | |
|     );
 | |
|   }
 | |
| 
 | |
|   static void info(dynamic msg, [dynamic error, StackTrace? stackTrace]) {
 | |
|     if (isReleaseVersion()) {
 | |
|       log(0, toNativeUtf8(msg));
 | |
|     } else {
 | |
|       Log.shared._logger.i(msg, error, stackTrace);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   static void debug(dynamic msg, [dynamic error, StackTrace? stackTrace]) {
 | |
|     if (isReleaseVersion()) {
 | |
|       log(1, toNativeUtf8(msg));
 | |
|     } else {
 | |
|       Log.shared._logger.d(msg, error, stackTrace);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   static void warn(dynamic msg, [dynamic error, StackTrace? stackTrace]) {
 | |
|     if (isReleaseVersion()) {
 | |
|       log(3, toNativeUtf8(msg));
 | |
|     } else {
 | |
|       Log.shared._logger.w(msg, error, stackTrace);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   static void trace(dynamic msg, [dynamic error, StackTrace? stackTrace]) {
 | |
|     if (isReleaseVersion()) {
 | |
|       log(2, toNativeUtf8(msg));
 | |
|     } else {
 | |
|       Log.shared._logger.v(msg, error, stackTrace);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   static void error(dynamic msg, [dynamic error, StackTrace? stackTrace]) {
 | |
|     if (isReleaseVersion()) {
 | |
|       log(4, toNativeUtf8(msg));
 | |
|     } else {
 | |
|       Log.shared._logger.e(msg, error, stackTrace);
 | |
|     }
 | |
|   }
 | |
| }
 | |
| 
 | |
| bool isReleaseVersion() {
 | |
|   return kReleaseMode;
 | |
| }
 | |
| 
 | |
| Pointer<ffi.Utf8> toNativeUtf8(dynamic msg) {
 | |
|   return "$msg".toNativeUtf8();
 | |
| }
 |