Giter VIP home page Giter VIP logo

Comments (5)

ueman avatar ueman commented on June 28, 2024 5

Tagging @matanlurey since he told me to do so

from flutter.

matanlurey avatar matanlurey commented on June 28, 2024 2

Using debugPrint or surrounding print with if (kIsDebug) isn't even the same behavior though.

Problems:

  • debugPrint has nothing to do with other uses of the prefix debug in the framework, which imply debug mode.
  • The default print could be fixed in the Flutter embedder (read: not require zones) to make debugPrint unnecessary
  • It's not clear to users when to use dart:developer#log, which is also part of the API that ships with Flutter

from flutter.

matanlurey avatar matanlurey commented on June 28, 2024 1

Appreciate you filing this.

I don't have the authority to make such a change, but here is what I would do if I did:

  • Override print in the Flutter embedder to work the way debugPrint does today
  • Deprecate debugPrint (for the time being, have it just forward to print)

That would bring us down to 2 ways to do things - one that always works in every mode and device - and one for debug only. I expect folks would likely write higher-level utilities on top, but at least the core functionality in dart:* would work in a reasonable manner.


@darshankawar I don't think this is team-engine (yet), it's true the change would need to happen in the engine, but the framework team would need to sign off on the changes (and, in my proposal above, agree to deprecate debugPrint).

from flutter.

goderbauer avatar goderbauer commented on June 28, 2024

From the framework's point of view you should be using debugPrint (this is also enforced with the avoid_print lint, which is part of the recommended lint set for flutter). By convention (like anything starting with debug*) it should only be called from a debug context (i.e. within an assert or guarded by if (kIsDebug)), see also its documentation. It solves the throttling problem on some platforms and makes it really easy to intercept logs in tests (without requiring the use of error-prone zones).

I guess, it is not clear to me what problem this issue is describing that needs to be solved?

from flutter.

UsamaKarim avatar UsamaKarim commented on June 28, 2024

debugPrint. The name suggests that it will only log to the console in debug mode, but nope; it’s nothing to do with whether you’re in debug of release mode. Massive foot gun for people new to Dart. I suspect a lot of Dart apps are leaking all sorts of info because of this…

from flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.