Re: Method 'print' send "newline" to output. How to print w/o "newline" in browser console?

3,158 views
Skip to first unread message
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

James Wendel

unread,
May 12, 2013, 2:50:31 AM5/12/13
to mi...@dartlang.org
I don't believe there is anyway for console.log in javascript to print to the console without a newline (at least in Chrome).  With that, it makes sense to make "print" always print a newline.  If you don't want to print a newline from a terminal window, stdout is the way to go.

Jos Hirth

unread,
May 12, 2013, 7:20:52 AM5/12/13
to mi...@dartlang.org
The console interface is meant for logging. There is one line per message. Each log message has a level (log, debug, info, warn, error), some text, and a source (file name and line number).

Command line applications can also write to stdout (an IOSink).

On Sunday, May 12, 2013 7:24:55 AM UTC+2, mezoni wrote:
Method 'print' send "newline" to output. How to print w/o "newline" in browser console?

Someone lost sight of the something.
Maybe I am.
Maybe the developers.
Message has been deleted
Message has been deleted
Message has been deleted

Jos Hirth

unread,
May 12, 2013, 9:33:32 AM5/12/13
to mi...@dartlang.org
On Sunday, May 12, 2013 2:34:24 PM UTC+2, mezoni wrote:
Logging is meant for logging. But not console.

You can disagree with that all you want, but it won't change anything. The console API which was introduced by Firebug is meant for logging.

You don't really print to a browser's console, you're logging messages. There is one line per message.

There is no newline character. The next message is in the next line because every message gets its own line.
Message has been deleted

Jos Hirth

unread,
May 12, 2013, 10:43:55 AM5/12/13
to mi...@dartlang.org
On Sunday, May 12, 2013 4:35:04 PM UTC+2, mezoni wrote:
And this "console API" cannot be used without Firebug.

It became a sort-of standard. Chrome, Opera, and IE also support this API. Firefox itself (it's shipped with some dev tools nowadays) also supports it.

Well, Dart's print function (if used in the browser) uses that API. There also isn't anything else it could use. It's the only way to "print" something in the browser.
Message has been deleted

Lasse R.H. Nielsen

unread,
May 13, 2013, 8:44:02 AM5/13/13
to mi...@dartlang.org
Short of "alert".
Which would probably be really, really annoying :)
 
/L 'debugging javascript the old-school way!'
-- 
Lasse R.H. Nielsen - l...@google.com  
'Faith without judgement merely degrades the spirit divine'
Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K - Denmark - CVR nr. 28 86 69 84

Bob Nystrom

unread,
May 15, 2013, 7:45:50 PM5/15/13
to General Dart Discussion

On Sat, May 11, 2013 at 10:37 PM, mezoni <andrew...@gmail.com> wrote:
If the 'print' is a universal way to send a string to be printed (without thinking of the output device), how to print a string without a newline.

If you're running on the standalone VM, you can import dart:io and use stdout.print(...);

Without knowledge about about the "stdout".
Eg. in tests that running in web browser.

In this case, you'll want to build up the string yourself incrementally and then only call print() once you've reached the end of a line. Web browsers always put each console.log() call on its own line.

Cheers,

- bob
Message has been deleted

Bob Nystrom

unread,
May 16, 2013, 2:17:12 PM5/16/13
to General Dart Discussion

On Wed, May 15, 2013 at 8:41 PM, mezoni <andrew...@gmail.com> wrote:
But is not usefull to show progress bar.
10% 20% 30% (incrementally).
Especially asynchronously.

For that, you're probably better off doing an actual UI in the DOM. console.log() was never really designed for something like that, for better or worse.

Cheers,

- bob
Reply all
Reply to author
Forward
0 new messages