easy_logger 0.0.1
easy_logger: ^0.0.1 copied to clipboard

Flutter Android iOS web

Easy logger

EasyLogger

Getting Started #

🔩 Installation #

Add to your pubspec.yaml:

dependencies:
  easy_logger: <last_version>

⚙️ Configuration logger #

Create global logger value

import 'package:easy_logger/easy_logger.dart';

final EasyLogger logger = EasyLogger(
  name: 'NamePrefix',
  defaultLevel: LevelMessages.debug,
  enableBuildModes: [BuildMode.debug, BuildMode.profile, BuildMode.release],
  enableLevels: [LevelMessages.debug, LevelMessages.info, LevelMessages.error, LevelMessages.warning],
);

void main() async {
...
}

📜 EasyLogger properties #

PropertiesRequiredDefaultDescription
namefalse''Name prefix in the logging line.
defaultLevelfalseLevelMessages.infoDefault message level if no level is set when call [EasyLogger].
enableBuildModesfalse[BuildMode.debug, BuildMode.profile]List of available build modes in which logging is enabled.
enableLevelsfalse[LevelMessages.debug, LevelMessages.info, LevelMessages.error, LevelMessages.warning]List of available levels messages in which logging is enabled.
printerfalseeasyLogDefaultPrinter()Default function printing.

Usage #

Simle usage:

logger('Your log text');

Or you can set the message level

logger('Your log text', level: LevelMessages.info);

🐛 StackTrace #

[EasyLogger] support [StackTrace] dump sending:

try {
  //same code
} on Exception catch (e, stackTrace) {
   logger('same error', stackTrace: stackTrace);
}

🖨️ Customise message or build levels #

[EasyLogger] supported Flutter build modes. Read more about Build modes

// only debug and profile modes
logger.enableBuildModes = [BuildMode.debug, BuildMode.profile]

// logger off
logger.enableLevels = []

You can customize what levels of messages you need

// show only errors
logger.enableBuildModes = [LevelMessages.error]

🖨️ Customise printer function #

[EasyLogger] have easiest way to change default printer function. Create your custom printer and past like parameter in class.

EasyLogPrinter customLogPrinter = (
  Object object, {
  String name,
  StackTrace stackTrace,
  LevelMessages level,
}) {
  print('$name: ${object.toString()}');
};

final EasyLogger logger = EasyLogger(
  printer: customLogPrinter,
);

Or insert into class object

logger.printer = customLogPrinter;

🖨️ Helpers #

For easest using logger you can send messages without level parameter.

  logger.debug('your log text');
  logger.info('your log text');
  logger.warning('your log text');
  logger.error('your log text');
2
likes
80
pub points
95%
popularity

Easy logger

Documentation

API reference

Uploader

mr.aissat@gmail.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on easy_logger