dev_colorized_log 2.0.6 copy "dev_colorized_log: ^2.0.6" to clipboard
dev_colorized_log: ^2.0.6 copied to clipboard

A Flutter package for logging colorized text in developer mode.

Dev Colorized Log #

pub packageStar on Github

A Flutter package for logging colorized text in developer mode.

Usage #

See examples to /example folder, more please run example project.

/* Global settings:*/
Dev.enable = true; // whether log msg
Dev.isLogFileLocation = true; // whether log the location file info
Dev.defaultColorInt = 0; // default color text, int value from 0 to 107
Dev.isDebugPrint = true; // Dev.print whether only log on debug mode

/// V 2.0.4 newline replacement for better search visibility in console
Dev.isReplaceNewline = true; // whether replace newline characters (default false)
Dev.newlineReplacement = ' | '; // replacement string for newlines (default ' | ')

/// V 2.0.3
Dev.prefixName = 'MyApp'; // prefix name

/// V 2.0.2
Dev.isExeDiffColor = false; // whether execFinalFunc with different color

/// V 2.0.0 the lowest level threshold to execute the function of customFinalFunc
Dev.exeLevel = DevLevel.logWar;
Dev.customFinalFunc = (msg, level) {
  // e.g.: your custom write msg to file
  writeToFile(msg, level);
};


/// V 1.2.8 colorize multi lines
Dev.log('===================== Colorize multi lines log =====================');
const multiLines = '''
      🔴 [ERROR] UniqueID: 1
      🕒 Timestamp: 2
      📛 ErrorType: 3
      💥 ErrorMessage: 4
      📚 StackTrace: 5
    ''';
const multiLines2 = 'Error1\nError2\nError3';
Dev.logError(multiLines);
Dev.logError(multiLines2);
/// V 1.2.8 special error format log
Dev.print(e, error: e, level: DevLevel.logErr);
Dev.logError('$e', error: e);
Dev.exeError('$e', error: e, colorInt: 91);

// V1.2.6 whether log on multi platform consoles like Xcode, VS Code, Terminal, etc.
Dev.isMultConsoleLog = true;

// V1.2.2
Dev.isLogShowDateTime = true; // whether log the date time
Dev.isExeWithShowLog = true; // whether execFinalFunc with showing log
Dev.isExeWithDateTime = false; // whether execFinalFunc with date time

// V1.2.1
Dev.exe("Exec Normal");
Dev.exeInfo("Exec Info");
Dev.exeSuccess("Exec Success");
Dev.exeWarning("Exec Warning");
Dev.exeError("Exec Error");
Dev.exeBlink("Exec Blink");
Dev.exe("Exec Normal without log", isLog: false);

Dev.log('1.log success level', level: DevLevel.logSuc);
Dev.logSuccess('2.log success level');
Dev.log('1.log success level and exec', level: DevLevel.logSuc, execFinalFunc: true);
Dev.exe('2.log success level and exec', level: DevLevel.logSuc);
Dev.exeSuccess('3.log success level and exec');
// END

// V1.2.0 Execute the custom function
Dev.exe('!!! Exec Normal');
Dev.exe('!!! Exec Colorized text Info Without log', level: DevLevel.logInf, isMultConsole: true, isLog: false, colorInt: 101);
Dev.print('Colorized text print with the given level', level: DevLevel.logWar);
// END

// then every level log func contains execFinalFunc param:
Dev.log('Colorized text log to your process of log', execFinalFunc: true);

// V1.1.6 custom function to support your process of log
// Deprecated: Use exeFinalFunc instead (customFinalFunc will be removed in future versions)
// Dev.customFinalFunc = (msg, level) {
//   writeToFile(msg, level);  
// };

## Migration Guide

### From customFinalFunc to exeFinalFunc (v2.0.6+)

The `customFinalFunc` has been renamed to `exeFinalFunc` for better naming consistency. The old name is deprecated but still works for backward compatibility.

**Old way (deprecated):**
```dart
Dev.customFinalFunc = (msg, level) {
  writeToFile(msg, level);
};

New way (recommended):

Dev.exeFinalFunc = (msg, level) {
  writeToFile(msg, level);
};

Priority: If both exeFinalFunc and customFinalFunc are set, exeFinalFunc takes priority.

Infinite Recursion Prevention: The library automatically prevents infinite recursion when exeFinalFunc or customFinalFunc calls Dev logging methods (like Dev.exeError, Dev.exe, etc.) internally.

// Safe: This won't cause infinite recursion
Dev.exeFinalFunc = (msg, level) {
  writeToFile(msg, level);
  Dev.exeError('Also log this error'); // Won't trigger exeFinalFunc again
};

/* Log usage: */ Dev.log('Colorized text log'); // default yellow text Dev.logInfo('Colorized text Info'); // blue text Dev.logSuccess('Colorized text Success', execFinalFunc: true); // green text Dev.logWarning('Colorized text Warning'); // yellow text Dev.logError('Colorized text Error'); // red text Dev.logBlink('Colorized text blink', isSlow: true, isLog: true); // blink orange text

// Support to log on multi platform consoles like Xcode and VS Code Dev.print('Dev text print', isDebug: true); // default log only on debug mode

// Others: Dev.log('Colorized text log other customs', fileLocation: 'main.dart:90xx', colorInt: 96);

// Example: Multi-line log for better search visibility const errorDetails = '''Error occurred:

  • File: user.dart:123
  • Function: validateEmail()
  • Reason: Invalid format''';

// With replacement enabled (default): Dev.logError(errorDetails); // Output: Error occurred: | - File: user.dart:123 | - Function: validateEmail() | - Reason: Invalid format

// Example with messy whitespace: const messyLog = ''' Error:
Multiple spaces and tabs End with spaces ''';

// With replacement enabled - cleans up extra whitespace: Dev.logError(messyLog); // Output: Error: | Multiple spaces and tabs | End with spaces

// Without replacement: Dev.isReplaceNewline = false; Dev.logError(errorDetails); // Output: Error occurred: // - File: user.dart:123 // - Function: validateEmail() // - Reason: Invalid format


## Author

Visit my github: [janlionly](https://github.com/janlionly)<br>
Contact with me by email: janlionly@gmail.com

## Contribute
I would love you to contribute to **DevColorizedLog**

## License
**DevColorizedLog** is available under the MIT license. See the [LICENSE](https://github.com/janlionly/flutter_dev_colorized_log/blob/master/LICENSE) file for more info.
2
likes
160
points
867
downloads

Publisher

verified publisherjanlionly.dev

Weekly Downloads

A Flutter package for logging colorized text in developer mode.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on dev_colorized_log