Getting Started

🔩 Installation

Add to your pubspec.yaml:

  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

namefalse''Name prefix in the logging line.
defaultLevelfalseLevelMessages.infoDefault message level if no level is set when call EasyLogger.
enableBuildModesfalseBuildMode.debug, BuildMode.profileList of available build modes in which logging is enabled.
enableLevelsfalseLevelMessages.debug, LevelMessages.info, LevelMessages.error, LevelMessages.warningList of available levels messages in which logging is enabled.
printerfalseeasyLogDefaultPrinter()Default function printing.


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');