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

  • Home
  • SEARCH
  • 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 8638131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:38:57+00:00 2026-06-12T10:38:57+00:00

Our logging framework, like most logging frameworks, uses the __FUNCTION__ preprocessor macro to insert

  • 0

Our logging framework, like most logging frameworks, uses the __FUNCTION__ preprocessor macro to insert the current function into log files so that our logging looks like:

L4  T11332 609661594 [PreProcessorFunctions::RegenerateLinkIDs] [ENTER]
L4  T11332 609661594 [PreProcessorFunctions::RegenerateLinkIDs] [EXIT]
L4  T11332 609661594 [ConfigMerger::ValidateConfigObject] [ENTER]
L3  T11332 609661594 [ConfigMerger::ValidateConfigObject] Configuration Exists: 1

As we’ve started to use C++11 more, I’ve noticed that labmdas produce accurate yet unhelpful __FUNCTION__ output:

L4  T9604 609661594 [`anonymous-namespace'::<lambda1>::operator ()] Writing EMX config file: C:\windows\TEMP\CBE01448-32A2-493A-A9A1-2112F5709028\CA37BE5C-B398-4D61-980D-66B8E1E6D001\\EMXConfiguration.xml
L4  T11332 609661594 [`anonymous-namespace'::<lambda3>::operator ()] Writing Auditing config file: C:\windows\TEMP\CBE01448-32A2-493A-A9A1-2112F5709028\CA37BE5C-B398-4D61-980D-66B8E1E6D001\\Auditing.xml
L4  T11960 609661594 [`anonymous-namespace'::<lambda2>::operator ()] Writing UEM config file: C:\windows\TEMP\CBE01448-32A2-493A-A9A1-2112F5709028\CA37BE5C-B398-4D61-980D-66B8E1E6D001\\Configuration.xml

As you can see, all class scope has been lost and all we now know is that this logging statement came from an anonymous lambda. Does anyone have a good strategy for logging out the enclosing function? This would appear to be the most useful thing to log…

  • 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-06-12T10:38:58+00:00Added an answer on June 12, 2026 at 10:38 am

    I think the only workaround would be to expand __FUNCTION__ (or __func__ in C++11) in the enclosing function and capture that inside the lambda.

    void f(){
      auto& _func_ = __func__;
      [&]{ std::cout << _func_; };
    }
    

    I would tag this as a “quality of implementation” issue, though. GCC, for example, provides the __PRETTY_FUNCTION__ macro that expands much better for lambdas (and in general):

    #include <iostream>
    
    struct X{
      void f(){
        []{ std::cout << __PRETTY_FUNCTION__ << "\n"; }();
      }
    };
    
    int main(){
      X().f();
    }
    

    Output: X::f()::<lambda()>

    Live example.

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

Sidebar

Related Questions

Our project uses a macro to make logging easy and simple in one-line statements,
I am looking to introduce a logging framework into our existing Oracle application to
I'm working on a project that uses different log frameworks, for example: log4j, commons-logging
We'd like to use Winston for our logging in Node.js. But, we can't figure
We are using log4j+commons-logging in our current projects. Now we are mirgrating from log4j
we are currently implementing logging functionality with Log4net into our ASP.NET web-services. Therefore we
Our team would like to use NLog for our logging needs - it does
We have logging in place for any .Net Framework exceptions that occur in our
I have installed Tomcat, and using SLF4J as our logging framework. I copied slf4j-api-1.6.4.jar
Our logging class, when initialised, truncates the log file to 500,000 bytes. From then

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.