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't change colors for talker_flutter #223

Open
polemius opened this issue Apr 23, 2024 · 1 comment
Open

Can't change colors for talker_flutter #223

polemius opened this issue Apr 23, 2024 · 1 comment

Comments

@polemius
Copy link

Describe the bug
I can't redifine colors for talker_flutter. It uses the default one only.

Code

  final logger = TalkerLogger(
    settings: TalkerLoggerSettings(
      colors: {
        LogLevel.critical: AnsiPen()..red(),
        LogLevel.error: AnsiPen()..magenta(),
        LogLevel.info: AnsiPen()..red(),
      },
      enableColors: true,
    ),
    output: (String message) {
      if (kIsWeb) {
        // ignore: avoid_print
        print(message);
        return;
      }
      if ([TargetPlatform.iOS, TargetPlatform.macOS]
          .contains(defaultTargetPlatform)) {
        log(message, name: 'Talker');
        return;
      }
      debugPrint(message);
    },
  );

  logger.info('test');
  final talkerFlutter = TalkerFlutter.init(
    logger: logger,
  );
  talkerFlutter.info('test');

Screenshots
image

Desktop (please complete the following information):

  • OS: MacOS

Smartphone (please complete the following information):

  • Device: Android Emulator
@abdelaziz-mahdy
Copy link
Contributor

searching through the code of the package i found that when defining talkerflutter is overrides the logger settings for the colors

https://github.com/Frezyx/talker/blob/b6340fd184f06f58bd6526af26ff0d055215a1be/packages/talker/lib/src/talker.dart#L65C6-L77C6

this example will work

  final logger = TalkerLogger(
    settings: TalkerLoggerSettings(
      colors: {
        LogLevel.critical: AnsiPen()..red(),
        LogLevel.error: AnsiPen()..magenta(),
        LogLevel.info: AnsiPen()..red(),
      },
      enableColors: true,
    ),
    output: (String message) {
      if (kIsWeb) {
        // ignore: avoid_print
        print(message);
        return;
      }
      if ([TargetPlatform.iOS, TargetPlatform.macOS]
          .contains(defaultTargetPlatform)) {
        log(message, name: 'Talker');
        return;
      }
      debugPrint(message);
    },
  );

  logger.info('test');
  final talkerFlutter = TalkerFlutter.init(
      logger: logger,
      settings: TalkerSettings(colors: {
        TalkerLogType.critical: AnsiPen()..red(),
        TalkerLogType.error: AnsiPen()..magenta(),
        TalkerLogType.info: AnsiPen()..red(),
      }));
  talkerFlutter.info('test');

as you can see the colors defined TalkerFlutter.init will be used and the one on logger level will be ignored

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants