fw4spl
ItkLogger.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include <fwCore/base.hpp>
8 
9 #include <itkOutputWindow.h>
10 
14 class ItkLogger : public ::itk::OutputWindow
15 {
16 public:
17  typedef ItkLogger Self;
18  typedef ::itk::SmartPointer<Self> Pointer;
19 
20  itkTypeMacro(ItkLogger, ::itk::Object);
21 
22  static Pointer New();
23 
24  virtual void DisplayText(const char* _txt) override;
25  virtual void DisplayErrorText(const char* _txt) override;
26  virtual void DisplayWarningText(const char* _txt) override;
27  virtual void DisplayDebugText(const char* _txt) override;
28 
29 private:
30  ItkLogger();
31  virtual ~ItkLogger();
32 };
33 
34 //------------------------------------------------------------------------------
35 
36 ItkLogger::Pointer ItkLogger::New()
37 {
38  return ItkLogger::Pointer(new ItkLogger());
39 }
40 
41 //------------------------------------------------------------------------------
42 
43 ItkLogger::ItkLogger()
44 {
45 
46 }
47 
48 //------------------------------------------------------------------------------
49 
50 ItkLogger::~ItkLogger()
51 {
52 
53 }
54 
55 //------------------------------------------------------------------------------
56 
57 void ItkLogger::DisplayText(const char* _txt)
58 {
59  OSLM_INFO("[ITK]: " << _txt);
60 }
61 
62 //------------------------------------------------------------------------------
63 
64 void ItkLogger::DisplayErrorText(const char* _txt)
65 {
66  OSLM_ERROR("[ITK]: " << _txt);
67 }
68 
69 //------------------------------------------------------------------------------
70 
71 void ItkLogger::DisplayWarningText(const char* _txt)
72 {
73  OSLM_WARN("[ITK]: " << _txt);
74 }
75 
76 //------------------------------------------------------------------------------
77 
78 void ItkLogger::DisplayDebugText(const char* _txt)
79 {
80  OSLM_DEBUG("[ITK]: " << _txt);
81 }
82 
83 //------------------------------------------------------------------------------
84 
86 {
88  {
89  ItkLogger::Pointer logger = ItkLogger::New();
90  ::itk::OutputWindow::SetInstance(logger);
91  logger->Delete();
92  }
93 };
94 
95 //------------------------------------------------------------------------------
96 
97 static LoggerInstantiator instantiator;
#define OSLM_INFO(message)
Definition: spyLog.hpp:252
#define OSLM_ERROR(message)
Definition: spyLog.hpp:274
Outputs ITK messages to the fw4spl log.
Definition: ItkLogger.cpp:14
#define OSLM_WARN(message)
Definition: spyLog.hpp:263
#define OSLM_DEBUG(message)
Definition: spyLog.hpp:241