   Logging: querying namespace / class name
  Is there a way to find out what namespace you're currently in? Or what class your code is being called from? Both of those seem like they would be very helpful in a logging system.i.e.const char* GetNamespace()...Log( string( GetNamespace() ) + ": " + errorString );(I know my string syntax is Java-ish here... but you get the idea.)What do you guys do for Logging to get the component name to show up as the first substring in the log (if anything)? (Without typing it every time)   
  Don't think it's doable. There are a few preprocessor variables such as __LINE__ and __FILE__ which always hold the current line and file name you're in, and on Microsoft's Visual C++ you also get a couple of variables which hold the function name you're currently in, but I don't think there's a way to get just the class or the namespace.   ;  Have a look at this. http://msdn2.microsoft.com/en-us/library/b0084kay.aspx   ;Quote:Original post by Red AntDon't think it's doable. There are a few preprocessor variables such as __LINE__ and __FILE__ which always hold the current line and file name you're in, and on Microsoft's Visual C++ you also get a couple of variables which hold the function name you're currently in, but I don't think there's a way to get just the class or the namespace.__FUNCTION__ as well.... that would give the namespace and class name, as well as the function signature.;  __FUNCTION__ works for this, but make sure its supported if you are going to work with different compilers or on different systems.   ;  If your platform doesn't support __FUNCTION__, a simple workaround is to just do this:#if (MY_PLATFORM_HAS_NO_FUNCTION)    #define __FUNCTION__ ""#endif;__FUNCTION__... beautiful, thanks guys. And Windows only for this one, so I'll probably be all set. But I'll do a #ifndef/#define.   