Mantid
Loading...
Searching...
No Matches
Logger.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include "MantidKernel/DllConfig.h"
14
15#include <Poco/Message.h>
16
17#include <iosfwd>
18
19#include <memory>
20#include <string>
21
22//----------------------------------------------------------------------
23// Forward declaration
24//----------------------------------------------------------------------
26namespace Poco {
27class Logger;
28}
30
31namespace Mantid {
32namespace Kernel {
33
52class MANTID_KERNEL_DLL Logger {
53public:
54 // Our logger's priority types are the same as POCO's Message's types.
55 using Priority = Poco::Message::Priority;
56
57 static const std::string *PriorityNames;
58
60 Logger(const std::string &name);
62 void setName(const std::string &name);
63
65 void fatal(const std::string &msg);
67 void error(const std::string &msg);
69 void warning(const std::string &msg);
71 void notice(const std::string &msg);
73 void information(const std::string &msg);
75 void debug(const std::string &msg);
77 void accumulate(const std::string &msg);
79 void flush();
81 void flush(Priority);
82 void flushDebug();
83 void flushInformation();
84 void flushNotice();
85 void flushWarning();
86 void flushError();
87 void flushFatal();
88 void purge();
89
91 std::ostream &fatal();
93 std::ostream &error();
95 std::ostream &warning();
97 std::ostream &notice();
99 std::ostream &information();
101 std::ostream &debug();
102
104 void log(const std::string &message, const Priority &priority);
105
107 std::ostream &getLogStream(const Priority &priority);
108
110 void dump(const std::string &msg, const void *buffer, std::size_t length);
111
113 void setLevel(int level);
114
116 void setLevelOffset(int level);
117
119 int getLevelOffset() const;
120
122 int getLevel() const;
123
125 void setLevel(const std::string &level);
126
128 bool getEnabled() const;
129
131 void setEnabled(const bool enabled);
132
134 bool is(int level) const;
135
138 static void setLevelForAll(const int level);
139
141 static void shutdown();
142
143private:
144 // Disable default constructor
147 Logger(const Logger &);
150
152 Priority applyLevelOffset(Priority proposedLevel);
153
155 Poco::Logger *m_log;
157 std::unique_ptr<ThreadSafeLogStream> m_logStream;
158
163};
164
165} // namespace Kernel
166} // namespace Mantid
double error
Definition: IndexPeaks.cpp:133
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition: Logger.h:52
static const std::string * PriorityNames
Definition: Logger.h:57
bool m_enabled
The state of this logger, disabled loggers send no messages.
Definition: Logger.h:162
Poco::Message::Priority Priority
Definition: Logger.h:55
Poco::Logger * m_log
Internal handle to third party logging objects.
Definition: Logger.h:155
Logger & operator=(const Logger &)
Disable assignment.
std::unique_ptr< ThreadSafeLogStream > m_logStream
Allows stream operators for a logger.
Definition: Logger.h:157
Logger(const Logger &)
Disable copying.
int m_levelOffset
The offset of the logger.
Definition: Logger.h:160
Helper class which provides the Collimation Length for SANS instruments.
Definition: Algorithm.h:30