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

TalkerFlutter.init() not printing logs onto console with iOS 16 #139

Open
arhamsc opened this issue Aug 23, 2023 · 16 comments
Open

TalkerFlutter.init() not printing logs onto console with iOS 16 #139

arhamsc opened this issue Aug 23, 2023 · 16 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@arhamsc
Copy link

arhamsc commented Aug 23, 2023

Describe the bug
When developing on physical iOS device, TalkerFlutter.init() is not printing logs onto the console.

Smartphone:

  • Device: iPhone 13 Pro Max
  • OS: 16.6
  • Flutter Version: 3.13.0 (stable)

Additional context
When i shifted to just Talker(), it worked but prints special characters before and after the message - <....>

@nikhil7299
Copy link

@Frezyx I was using talker_logger to log Riverpod 2 state changes using the Provider Observer State Logger from official Riverpod 2 docs. Where I realized that iOS builds does not show colors in debug console. So I internally replaced the "print" with "devtools.log". Then It started working.

@arhamsc
Copy link
Author

arhamsc commented Sep 7, 2023

@nikhil7299 in Talker_Flutter.init(), the log method for iOS is debug log, as per my inspection of the package. If you could share which file you changed it would help me produce a similar outcome as yours.

@nikhil7299
Copy link

I just replaced print to devtools.log inside logger.dart in talker_logger like this -

Previous Code :-

import 'package:talker_logger/talker_logger.dart';

class TalkerLogger {
  TalkerLogger({
    this.settings = const TalkerLoggerSettings(),
    LoggerFilter? filter,
    this.formatter = const ExtendedLoggerFormatter(),
    void Function(String message)? output,
  }) {
    // ignore: avoid_print
    _output =
        output ?? (String message) => message.split('\n').forEach(print);
    _filter = filter ?? LogLevelFilter(settings.level);
    ansiColorDisabled = false;
  }
...

New Code :-

import 'package:talker_logger/talker_logger.dart';
import 'dart:developer' as devtools;

class TalkerLogger {
  TalkerLogger({
    this.settings = const TalkerLoggerSettings(),
    LoggerFilter? filter,
    this.formatter = const ExtendedLoggerFormatter(),
    void Function(String message)? output,
  }) {
    // ignore: avoid_print
    _output =
        output ?? (String message) => message.split('\n').forEach(devtools.log);
    _filter = filter ?? LogLevelFilter(settings.level);
    ansiColorDisabled = false;
  }
...

=> Also run in debug mode as devtool log works in debug mode.

@arhamsc
Copy link
Author

arhamsc commented Sep 9, 2023

Did you check TalkerFlutter.init(), source code? It is actually similar to this. But when I used that started for a few times it was printing fine but suddenly it stopped printing.

@Frezyx
Copy link
Owner

Frezyx commented Sep 11, 2023

Hello @arhamsc !
Can you provide your code example ?

I'm using talker_flutter: 3.2.10 version in my projects and my logs console is colored as it should be

@arhamsc
Copy link
Author

arhamsc commented Oct 11, 2023

@Frezyx
Sorry for the late reply, but the code is as follows:

 _talker = TalkerFlutter.init();

I tried doing what @nikhil7299 did, the devtools.log is not working actually, when i reverted it back to 'print' it worked, but with the special characters as mentioned earlier without colors.

@nikhil7299
Copy link

@arhamsc Did you run in debug mode or without debugging? Developer tools .log() works only in debug mode.

@arhamsc
Copy link
Author

arhamsc commented Oct 13, 2023

@arhamsc Did you run in debug mode or without debugging? Developer tools .log() works only in debug mode.

I ran the app in debug mode. And then tried changing back and forth from developer log and print, only with print it worked not with developer logs.

EDIT
you are referring to --debug flag with flutter run, right?

@arhamsc
Copy link
Author

arhamsc commented Nov 1, 2023

Is there any update on this thread? @Frezyx
Is it due to the new devctl command that apple has introduced which requires flutter to be run via xcode?

@RNOVOSELOV
Copy link

@Frezyx @arhamsc
I also reproduced  same problem.

In VSCode logs are displayed correctly, but Android Studio (Giraffe version) does not  show the logs or shows them without color and not completely (tested on iOS 15 & iOS16)

Android and Web are works correctly on both IDE.

@RNOVOSELOV
Copy link

RNOVOSELOV commented Nov 4, 2023

final sl = GetIt.instance;

void _setupTakerLogger() {
  sl.registerLazySingleton<Talker>(() => TalkerFlutter.init());
  Bloc.observer = TalkerBlocObserver(talker: sl.get<Talker>());
  FlutterError.onError =
      (details) => sl.get<Talker>().handle(details.exception, details.stack);
}

Android Studio's console log example, when run on iOS 15/16

[Talker] �[38;5;4m┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────�[0m
�[38;5;4m│ [INFO] | 14:43:25 763ms | _onSplashPageLoaded - Read token from shared preferences: null�[0m
�[38;5;4m└──────────────────────────────────────────────────────────────────────────────────────────────────────────────�[0m

@Frezyx Frezyx added the bug Something isn't working label Dec 4, 2023
@Frezyx
Copy link
Owner

Frezyx commented Dec 4, 2023

Hello guys!
Thank you for reporting this error. Currently I don't know why logs don't shows in console for something apple devices
I will check this in near future!

@nikhil7299
Copy link

@arhamsc
Yes I am talking about 'flutter run --debug' but do not use command line, just press F5, the logs will be shown in the Debug Console and not in Terminal.
Also when you modify the internal code of TalkerLogger, make sure to reload "VS Code" window and re-run your flutter app using F5.

@arhamsc
Copy link
Author

arhamsc commented Dec 16, 2023

@nikhil7299 Yes I used the internal vs code run command. And I have tried the steps you have mentioned. It seems to be the general problem of the apple making internal changes which aren't allowing the logs in general within flutter framework.

@SharbelOkzan
Copy link

Any updates/workaround?

@arhamsc
Copy link
Author

arhamsc commented May 21, 2024

It seems to be printing onto IoS console in a neater way now.

Device: Iphone 14 Pro Max
IOS: 17

But there is not color coding and has some weird alignment and symbols.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants