Skip to content

An easy-to-use logging tool for you to integrate in you project, supporting logging to console or file, supporting configuring according to your environment

License

Notifications You must be signed in to change notification settings

arisorgcn/aris_flutter_logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aris_flutter_logger

An easy-to-use logging tool for you to integrate in you project, supporting logging to console, file(rotated formatted), supporting configuring according to your environment(development or production)

Usage

Step1 add package to your pubspec.yaml, then run pub get

aris_flutter_logger: ^1.0.0+1

Step2 add below method in main.dart

  • development environment
Future init() async {
  WidgetsFlutterBinding.ensureInitialized();

  // initialize logger
  await ArisLogConfig.init(
    printer: DevelopmentLogPrinter(methodCount: 0, errorMethodCount: 0, colors: false, printEmojis: false, printTime: true),
    filter: DevelopmentFilter(),
    logLevel: Level.debug,
    logOutputTypes: [LogOutputType.CONSOLE_OUTPUT, LogOutputType.ROTATE_FILE_OUTPUT],
    rotateFileType: RotateFileType.DAY,
  );
}
  • production environment
Future init() async {
  WidgetsFlutterBinding.ensureInitialized();

  // initialize logger
  await ArisLogConfig.init(
    printer: ProductionLogPrinter(printTime: true),
    filter: ProductionFilter(),
    logLevel: Level.info,
    logOutputTypes: [LogOutputType.ROTATE_FILE_OUTPUT],
    rotateFileType: RotateFileType.DAY,
  );
}

Step3 in main method before runApp(MyApp()), add await init();

Future main() async {
  await init();

  runApp(MyApp());
}

Step4 in page dart file or somewhere else

void initLogging() {
  final ArisTagLogger logger = ArisLogUtils.getTagLogger();
  final Logger logger = ArisLogUtils.getLogger();
  logger.i('Info Message');
  logger.iFmt('%s %s', ["Info message in ", "initLogging"]);
}

About

An easy-to-use logging tool for you to integrate in you project, supporting logging to console or file, supporting configuring according to your environment

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages