Ice 3.8
C++ API Reference
Loading...
Searching...
No Matches
Logger.h
1// Copyright (c) ZeroC, Inc.
2
3#ifndef ICE_LOGGER_H
4#define ICE_LOGGER_H
5
6#include "Config.h"
7
8#include <memory>
9#include <string>
10
11namespace Ice
12{
13 class Logger;
14
15 /// A shared pointer to a Logger.
16 using LoggerPtr = std::shared_ptr<Logger>;
17
18 /// Represents Ice's abstraction for logging and tracing. Applications can provide their own logger by
19 /// implementing this abstraction and setting a logger on the communicator.
20 /// @see InitializationData
21 /// @headerfile Ice/Ice.h
22 class ICE_API Logger
23 {
24 public:
25 virtual ~Logger();
26
27 // We use const std::string& and not std::string_view for the log messages because implementations commonly
28 // send the message to C APIs that require null-terminated strings.
29 // The message itself is also often constructed from a string produced by an ostringstream.
30
31 /// Prints a message. The message is printed literally, without any decorations such as executable name or
32 /// timestamp.
33 /// @param message The message to log.
34 virtual void print(const std::string& message) = 0;
35
36 /// Logs trace message.
37 /// @param category The trace category.
38 /// @param message The trace message to log.
39 virtual void trace(const std::string& category, const std::string& message) = 0;
40
41 /// Logs a warning message.
42 /// @param message The warning message to log.
43 /// @see #error
44 virtual void warning(const std::string& message) = 0;
45
46 /// Logs an error message.
47 /// @param message The error message to log.
48 /// @see #warning
49 virtual void error(const std::string& message) = 0;
50
51 /// Returns this logger's prefix.
52 /// @return The prefix.
53 virtual std::string getPrefix() = 0;
54
55 /// Returns a clone of the logger with a new prefix.
56 /// @param prefix The new prefix for the logger.
57 /// @return A logger instance.
58 virtual LoggerPtr cloneWithPrefix(std::string prefix) = 0;
59 };
60}
61
62#endif
virtual void warning(const std::string &message)=0
Logs a warning message.
virtual void trace(const std::string &category, const std::string &message)=0
Logs trace message.
virtual std::string getPrefix()=0
Returns this logger's prefix.
virtual void print(const std::string &message)=0
Prints a message.
virtual LoggerPtr cloneWithPrefix(std::string prefix)=0
Returns a clone of the logger with a new prefix.
virtual void error(const std::string &message)=0
Logs an error message.
Represents Ice's abstraction for logging and tracing.
Definition Logger.h:23
std::shared_ptr< Logger > LoggerPtr
A shared pointer to a Logger.
Definition Logger.h:16
The Ice RPC framework.
Definition SampleEvent.h:59