[Insight-users] File and linenumber info when using the itk:Logger ?

Luis Ibanez luis.ibanez at kitware.com
Sat Mar 6 17:21:55 EST 2010


Hi Motes,

The Loggers do not report FILE and LINE number
automatically.

If you want this information to make it to the log,
here is what you could do:


When composing the message that you sent
to the log, include the variables:

            __FILE__ and __LINE__


See for example, how this is done in the

                 itkWarningMacro()

in the file

    Insight/Code/Common/itkMacro.h

The expression will look like:

 << "message " __FILE__ ", line " << __LINE__ << std::endl;



Regards,


    Luis


----------------------------------------------
On Tue, Mar 2, 2010 at 9:30 AM, motes motes <mort.motes at gmail.com> wrote:
> I am using the itk:Logger in my application:
>
>
>
>
> #include "itkLogger.h"
> #include "itkStdStreamLogOutput.h"
>
> int main(){
>
>  itk::StdStreamLogOutput::Pointer output = itk::StdStreamLogOutput::New();
>  output->SetStream(std::cout);
>  itk::Logger::Pointer logger = itk::Logger::New();
>  logger->SetName("RegistrationLogger");
>  logger->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE);
>  logger->SetPriorityLevel(itk::LoggerBase::INFO);
>  logger->AddLogOutput(output);
>  logger->Write(itk::LoggerBase::INFO, "doing stuff\n");
>
> return 0;
>
> }
>
> when I run the above app I get:
>
> 2010 Mar 02 15:26:44  :  RegistrationLogger  (INFO) doing stuff
>
> But is it not possible to get file and linenumber information added
> automatically like when using eg. log4cxx ?
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list