RStudio Launcher Plugin SDK  1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
ILogDestination.hpp
1 /*
2  * ILogDestination.hpp
3  *
4  * Copyright (C) 2022 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant to the terms of a commercial license agreement
7  * with RStudio, then this program is licensed to you under the following terms:
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
10  * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
11  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
15  * Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  */
23 
24 #ifndef LAUNCHER_PLUGINS_I_LOG_DESTINATION_HPP
25 #define LAUNCHER_PLUGINS_I_LOG_DESTINATION_HPP
26 
27 #include <Noncopyable.hpp>
28 
29 #include <string>
30 
31 #include <logging/Logger.hpp>
32 
33 namespace rstudio {
34 namespace launcher_plugins {
35 namespace logging {
36 
41 {
42 public:
54  explicit ILogDestination(const std::string& in_id,
55  LogLevel in_logLevel,
56  LogMessageFormatType in_formatType,
57  bool in_reloadable) : m_id(in_id), m_logLevel(in_logLevel), m_formatType(in_formatType), m_reloadable(in_reloadable) {}
58 
59 
63  virtual ~ILogDestination() = default;
64 
70  std::string getId() const { return m_id; }
71 
78 
85 
91  bool isReloadable() const { return m_reloadable; }
92 
98  virtual void refresh(const RefreshParams& in_refreshParams = RefreshParams()) = 0;
99 
106  virtual void writeLog(LogLevel in_logLevel, const std::string& in_message) = 0;
107 
108 protected:
112  std::string m_id;
113 
118 
123 
128 };
129 
130 } // namespace logging
131 } // namespace launcher_plugins
132 } // namespace rstudio
133 
134 #endif
rstudio::launcher_plugins::logging::ILogDestination::isReloadable
bool isReloadable() const
Gets whether or not the log destination is reloadable.
Definition: ILogDestination.hpp:91
rstudio::launcher_plugins::logging::ILogDestination::m_logLevel
LogLevel m_logLevel
The maximum level of log messages to write for this logger.
Definition: ILogDestination.hpp:117
rstudio::launcher_plugins::logging::ILogDestination::~ILogDestination
virtual ~ILogDestination()=default
Virtual destructor to allow for inheritance.
rstudio::launcher_plugins::logging::ILogDestination
Interface which allows a logger to write a log message to a destination.
Definition: ILogDestination.hpp:40
rstudio::launcher_plugins::logging::ILogDestination::writeLog
virtual void writeLog(LogLevel in_logLevel, const std::string &in_message)=0
Writes a message to this log destination.
rstudio::launcher_plugins::logging::ILogDestination::getLogLevel
LogLevel getLogLevel()
Gets the maximum level of logs that will be written to this log destination.
Definition: ILogDestination.hpp:77
rstudio::launcher_plugins::logging::ILogDestination::refresh
virtual void refresh(const RefreshParams &in_refreshParams=RefreshParams())=0
Refresh the log destintation. Ensures that the log does not have any stale file handles.
rstudio::launcher_plugins::logging::ILogDestination::ILogDestination
ILogDestination(const std::string &in_id, LogLevel in_logLevel, LogMessageFormatType in_formatType, bool in_reloadable)
Constructor.
Definition: ILogDestination.hpp:54
rstudio::launcher_plugins::logging::ILogDestination::m_formatType
LogMessageFormatType m_formatType
The log message format type.
Definition: ILogDestination.hpp:122
rstudio::launcher_plugins::logging::LogLevel
LogLevel
Enum which represents the level of detail at which to log messages.
Definition: Logger.hpp:86
rstudio::launcher_plugins::logging::RefreshParams
A struct encapsulating various params to pass when refreshing log destinations. This carries data tha...
Definition: Logger.hpp:67
rstudio::launcher_plugins::logging::ILogDestination::getLogMessageFormatType
LogMessageFormatType getLogMessageFormatType()
Gets the log message format type for this log destination.
Definition: ILogDestination.hpp:84
Logger.hpp
rstudio::launcher_plugins::logging::ILogDestination::getId
std::string getId() const
Gets the unique ID of the log destination.
Definition: ILogDestination.hpp:70
rstudio::launcher_plugins::Noncopyable
Class which can be inherited from to disallow copying of its child classes.
Definition: Noncopyable.hpp:34
rstudio::launcher_plugins::logging::ILogDestination::m_reloadable
bool m_reloadable
Whether or not the log destination is reloadable (i.e. it will be destroyed when the global logger is...
Definition: ILogDestination.hpp:127
rstudio::launcher_plugins::logging::LogMessageFormatType
LogMessageFormatType
Enum which represents the format type for log messages.
Definition: Logger.hpp:107
rstudio::launcher_plugins::logging::ILogDestination::m_id
std::string m_id
The unique ID of the log destination.
Definition: ILogDestination.hpp:112