zeytinlogger 1.0.0 copy "zeytinlogger: ^1.0.0" to clipboard
zeytinlogger: ^1.0.0 copied to clipboard

ZeytinLogger allows you to capture your error messages, analyses, and tests in your projects, store them with ZeytinLogger, and list them.

example/zeytinlogger_example.dart

import 'package:zeytinlogger/zeytinlogger.dart';

void main() async {
  final logger = ZeytinLogger();

  // 1. Initialization
  await logger.init('./logs_directory');

  // 2. Adding Different Types of Logs
  await logger.info(InfoLog(message: 'Application started successfully.'));
  await logger.success(SuccessLog(message: 'User logged in.'));
  await logger.error(ErrorLog(errorMessage: 'Connection timed out.'));
  await logger.attention(AttentionLog(message: 'Storage space is below 10%.'));
  await logger.any(
    AnyLog(tag: "login", data: {'action': 'click', 'button': 'login'}),
  );

  // 3. Fetching Logs (Descending by default)
  final allErrors = await logger.getErrorLogs();
  for (var error in allErrors) {
    print('Error: ${error.toMap()}');
  }

  // 4. Filtering Logs (Where)
  final timeoutErrors = await logger.whereErrorLogs(
    (log) => log['code'] == 408,
  );
  print('Timeout Errors Count: ${timeoutErrors.length}');

  // 5. Checking for a Specific Log (Contains)
  final hasStorageWarning = await logger.containsAttentionLog(
    (log) => log['message']?.contains('Storage') ?? false,
  );
  print('Is there a storage warning? $hasStorageWarning');

  // 6. Conditional Log Removal (RemoveWhere)
  await logger.removeWhereAnyLog((log) => log['action'] == 'click');

  // 7. Clearing Categories and All Logs
  await logger.clearInfoLogs(); // Clears only Info logs
  await logger.clearAllLogs(); // Clears all log boxes
}
1
likes
160
points
0
downloads

Publisher

verified publisherjeafriday.com

Weekly Downloads

ZeytinLogger allows you to capture your error messages, analyses, and tests in your projects, store them with ZeytinLogger, and list them.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

zeytinx

More

Packages that depend on zeytinlogger