Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7554909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:27:39+00:00 2026-05-30T11:27:39+00:00

I have a logging function which accepts variadic parameters. This works fine for say

  • 0

I have a logging function which accepts variadic parameters. This works fine for say android logging and printf, but I want to do the same with std::cout and file streams. Is there an easy way solve this?

void LogManagerImpl::LogInfo(const char* msg, ...)
    {
        va_list argptr;
        va_start(argptr, msg);

        /* Log to stdout */
        if (mLogToStdOut)
        {
            #ifdef ANDROID
                __android_log_vprint(ANDROID_LOG_INFO, __ENGINE_LOG_TAG, msg, argptr);
            #elif defined _WIN32 || _WIN64
                //printf ("%s:%s",__ENGINE_LOG_TAG,"INFO:"); vprintf(msg, argptr); printf("\n");
                // how do I do the same as above except with for example std::cout?
            #endif
        }

        /* Log to file */
        if (mLogToFile)
        {
                      // TODO

        }

        va_end(argptr);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:27:41+00:00Added an answer on May 30, 2026 at 11:27 am

    Don’t try to use a variadic wrapper for C++ streams, just use the corresponding C API such as vprintf/vnsprintf. Wrapping streams in this way just throws away all the benefits and causes additional complexity.

    Why not have your wrapper API use streams, and map them to printf on Android platforms. That way you get all the benefits of streams and only lose them on platforms that don’t natively support them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I already rolled my own custom logging function, which works quite well. But
Let's say I have this class Logger that is logging strings in a low-priority
I have a rather large app which works in the simulator but creates in
Scratching my head here: I have an application which works fine in Debug+Release if
I have a logging function in T-SQl similiar to this: CREATE PROCEDURE [logging] @PROCEDURE
I have an instance of a logging class logger, this class has a function
As stated in the question I have a static function (for logging) which I
I have a python test in which I want to test if the logging
I have a static logging function that uses StringBuilder to concatenate a bunch of
I have a logging table which has three columns. One column is a unique

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.