Giter VIP home page Giter VIP logo

Comments (4)

sebthom avatar sebthom commented on May 24, 2024

Since no well established/maintained logging framework or facade for Haxe exists, we are just using the trace method to output some infos. If you want to suppress these messages you will need to override the trace method and discard them.

Something like this (untested):

final realTrace = haxe.Log.trace;
haxe.Log.trace = function(v:Dynamic, ?pos: haxe.PosInfos ):Void {
  if (pos.className.indexOf("hx.concurrent") == -1) realTrace(v, pos);
}

from haxe-concurrent.

acarioni avatar acarioni commented on May 24, 2024

IMHO a library should not assume that printing to the standard output is safe: partly because diagnostic logs are just annoying who is not interested in and partly because a console environment may not be available (see this issue for example, where the error is indirectly caused by haxe-concurrent trying to call trace in the virtual console of Spyder IDE).

On the other hand tweaking haxe.Log just for a single library is a little awkward. Further if haxe-concurrent is not used by an application but by another library (as in my case), there isnโ€™t a unique entry-point where one can redefine haxe.Log safely.

It would be better if haxe-concurrent wraps the calls to trace in a #if HX_CONCURRENT_LOG block. So only the users who are interested can compile the library with the log enabled.

from haxe-concurrent.

sebthom avatar sebthom commented on May 24, 2024

You are mixing up usage of trace vs Sys.stdout.write. We are not printing directly to stdout, we use the trace function from the class haxe.Log (which actually is for logging). Since the trace function receives all required context information via the pos argument for you to decide which messages to filter out, the approach I laid out is perfectly valid. Rebinding the trace function is even described in the official Haxe docs https://api.haxe.org/haxe/Log.html

If you are not interested in any traces at all you can use the --no-traces compiler option as described here https://haxe.org/manual/debugging-trace-log.html#removing-traces

from haxe-concurrent.

acarioni avatar acarioni commented on May 24, 2024

Iโ€™m not entirely convinced that using trace as a log surrogate is good idea, but anyway the compiler flag --no-traces can be enough to resolve this specific issue.
Thanks for the hint.

from haxe-concurrent.

Related Issues (17)

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.