dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Alternative to cout logging in Windows Environment.

  1. #1
    Join Date
    Dec 2010
    Posts
    907

    Alternative to cout logging in Windows Environment.

    I find out that Java println and many fold faster than cout in C++.
    I am currently using cout as a quick visual logging tool.
    I wonder how I can make the same lightning fast text output in C++?
    Thanks
    Jack

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,555

    Re: Alternative to cout logging in Windows Environment.


  3. #3
    Join Date
    Dec 2010
    Posts
    907

    Re: Alternative to cout logging in Windows Environment.

    How can I output to a separate standalone console pane just for debugging instead of interweaving other debug outputs to the same pane?
    Thanks
    Jack

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,602

    Re: Alternative to cout logging in Windows Environment.

    What I usually prefer is using plain text logging to disk file (lightning fast ) along with a tool that autodetects file update and dispalys the file tail (in my case it's always FAR Manager viewer). The most beatiful thing about this approach is that the log remains available for offline analysis, e.g. grepping.

    Oh, one more thing: I never use cout, but always do use printf. Lightning fast
    Last edited by Igor Vartanov; September 19th, 2015 at 05:51 PM.
    Best regards,
    Igor

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,919

    Re: Alternative to cout logging in Windows Environment.

    Oh, one more thing: I never use cout, but always do use printf. Lightning fast
    It has been shown in these forums previously that i/o using the c library functions is faster than using the c++ i/o streams (for MS).
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.4.0)

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Alternative to cout logging in Windows Environment.

    things like this Always end up being about programmer convenience vs performance.

    if speed is really your concern. Then low level file IO with your own formatting is going to beat the pants out of anything.

    C FILE io offers buffered and formatted IO at a cost.

    C++ io offers buffered, formatted, and typed IO (and easy changing to other stream types) at an even larger cost.

    Part of the problem of cout in particular is that output is constantly being flushed, which negates part of buffering features.
    file stream io can be made faster by increasing the internal buffer.

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,172

    Re: Alternative to cout logging in Windows Environment.

    Why not use a logging library that allows you to configure the outputs (log to file, log to console, log to the debugger, log to the event viewer (windows), etc.)?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)