Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we add an option to show most recent logs first. #5

Closed
saad-palapa opened this issue Nov 25, 2022 · 1 comment
Closed

Can we add an option to show most recent logs first. #5

saad-palapa opened this issue Nov 25, 2022 · 1 comment
Assignees
Labels
T: Feature Type: :tada: New Features

Comments

@saad-palapa
Copy link

This is what I have in a wrapper class:

import 'package:debug_overlay/debug_overlay.dart';
import 'package:flutter/widgets.dart';

class Logger {
  static final logs = LogCollection();

  static void info(String message) => _log(message, DiagnosticLevel.info);
  static void debug(String message) => _log(message, DiagnosticLevel.debug);
  static void error(String message) => _log(message, DiagnosticLevel.error);

  static void _log(String message, DiagnosticLevel level) {
    // Flutter will wait until the current build is completed before executing this code
    WidgetsBinding.instance.addPostFrameCallback((_) {
      debugPrint(message);
      logs.add(
        Log(level: level, message: message),
      );

      final reversed = logs.logs.reversed.toList();
      logs.logs.clear();
      logs.logs.addAll(reversed);
    });
  }
}

This is my hacky way to show the most recent logs first. Can we instead have that as an option?

@saad-palapa saad-palapa added the T: Feature Type: :tada: New Features label Nov 25, 2022
@JonasWanke JonasWanke self-assigned this Jan 24, 2023
@JonasWanke
Copy link
Owner

I added a toggle icon as part of v0.2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: Feature Type: :tada: New Features
Projects
None yet
Development

No branches or pull requests

2 participants