logging icon indicating copy to clipboard operation
logging copied to clipboard

dart:developer log is inconsistent between IDE's and platforms

Open JCKodel opened this issue 2 years ago • 1 comments

I was experimenting with ANSI colors in log to create a new logging package, using both print and dart:developer/log functions.

I found some inconsistences:

  1. dart:developer.log doesn't work at all in web platform. Nothing is printed. (print works just fine). Console also doesn't work (meaning: running in a console using flutter run)

  2. Consoles (including VSCode console) shows ANSI color for both print and log, but Android Studio only shows color for print.

Example code:

const greenForeground = "\u001b[32m";
const yellowBackground = "\u001b[43;1m";
const resetColor = "\u001b[0m";

print("${greenForeground}${yellowBackground}This is print with green foreground and yellow background.${resetColor}");
log("${greenForeground}${yellowBackground}This is dart:developer.log with green foreground and yellow background.${resetColor}");

VSCode output for MacOS (and maybe Android, iOS, Linux and Windows): image

Same for Android Studio Electric Eel (#AI-221.6008.13.2211.9477386) (notice log doesn't work with ANSI codes) image

Running on Chrome: This is VSCode: image

This is Chrome console (missing the log entry and also the green color should be dark, not bright (considering ANSI 16 colors specification)): image

Running on console (default MacOS Terminal app) (Notice here is the wrong yellow (should be brighter, and log is missing)): MacOS build: image

Web build: image

Considering print is limited (specially on Android), dart:developer should provide a better cross-platform log option that is reliable no matter the platform it is running =(

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.3, on macOS 12.6.2 21G320 darwin-x64, locale en-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.75.0)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!

JCKodel avatar Feb 14 '23 16:02 JCKodel

https://issuetracker.google.com/issues/288641191 i Have same issue and i recommend you to raise issue here : https://github.com/flutter/flutter-intellij/issues

Raj-GMITS avatar Jun 28 '23 12:06 Raj-GMITS