Logging from within helper functions

38 views
Skip to first unread message

emile.co...@gmail.com

unread,
Nov 7, 2014, 6:27:18 PM11/7/14
to catch...@googlegroups.com
Is it possible to do logging (INFO, WARN, etc..) from within helper functions? I'm trying to do something like this:

static bool filesMatch(const std::string& path1, const std::string& path2)
{
    INFO("While comparing files '" << path1 << "' and '" << path2 << "'");
   
    // etc...

    if (line1 != line2)
    {
        INFO("Mismatch at line " << lineNo << ":\n"
             << line1 << "\nvs\n" << line2);
    }

    // etc...
}

and in my test case:

CHECK( filesMatch(path1, path2) );

But I don't see any logging messages when  the CHECK fails.

emile.co...@gmail.com

unread,
Nov 7, 2014, 7:55:12 PM11/7/14
to catch...@googlegroups.com
I figured it out. I simply need to FAIL from within my helper function and the logging messages will appear.

Phil Nash

unread,
Nov 9, 2014, 3:22:41 PM11/9/14
to catch...@googlegroups.com
Yes. The logging macros are only valid for the current scope
Reply all
Reply to author
Forward
0 new messages