Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
EthanLogPlugin.h
1 /*
2 * If not stated otherwise in this file or this component's LICENSE file the
3 * following copyright and licenses apply:
4 *
5 * Copyright 2016 Sky UK
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19 /*
20  * File: EthanLogPlugin.h
21  *
22  */
23 #ifndef ETHANLOGPLUGIN_H
24 #define ETHANLOGPLUGIN_H
25 
26 #include <IDobbyPlugin.h>
27 #include <PluginBase.h>
28 
29 #include <string>
30 #include <mutex>
31 
32 
33 class EthanLogLoop;
34 
35 // -----------------------------------------------------------------------------
48 class EthanLogPlugin final : public PluginBase
49 {
50 public:
51  EthanLogPlugin(const std::shared_ptr<IDobbyEnv>& env,
52  const std::shared_ptr<IDobbyUtils>& utils);
53  ~EthanLogPlugin() final;
54 
55 public:
56  std::string name() const final;
57 
58  unsigned hookHints() const final;
59 
60 public:
61  bool postConstruction(const ContainerId& id,
62  const std::shared_ptr<IDobbyStartState>& startupState,
63  const std::string& rootfsPath,
64  const Json::Value& jsonData) final;
65 
66  bool preStart(const ContainerId& id,
67  pid_t pid,
68  const std::string& rootfsPath,
69  const Json::Value& jsonData) final;
70 
71 private:
72  unsigned parseLogLevels(const Json::Value& jsonArray) const;
73 
74 private:
75  const std::string mName;
76  const std::shared_ptr<IDobbyUtils> mUtilities;
77  const std::shared_ptr<EthanLogLoop> mLogLoop;
78 
79 private:
80  const unsigned mDefaultLogLevelsMask;
81  int mDevNullFd;
82 };
83 
84 
85 #endif // !defined(ETHANLOGPLUGIN_H)
A wrapper around a std::string, used to add some type definition to to an id and also to sanity check...
Definition: ContainerId.h:41
Definition: EthanLogLoop.h:46
Plugin library that create a DIAG logging pipe for a container.
Definition: EthanLogPlugin.h:49
bool preStart(const ContainerId &id, pid_t pid, const std::string &rootfsPath, const Json::Value &jsonData) final
We hook the preStart point so we can tell the EthanLog code the base pid of the container.
Definition: EthanLogPlugin.cpp:276
unsigned parseLogLevels(const Json::Value &jsonArray) const
Parses the supplied json array and returns a bitmask of the log levels.
Definition: EthanLogPlugin.cpp:307
std::string name() const final
Boilerplate that just returns the name of the hook.
Definition: EthanLogPlugin.cpp:115
unsigned hookHints() const final
Indicates which hook points we want and whether to run the asynchronously or synchronously with the o...
Definition: EthanLogPlugin.cpp:128
bool postConstruction(const ContainerId &id, const std::shared_ptr< IDobbyStartState > &startupState, const std::string &rootfsPath, const Json::Value &jsonData) final
We hook the postConstruction point to create a logging pipe for the container which we then given to ...
Definition: EthanLogPlugin.cpp:155
Basic object that provides the default overrides for a plugin.
Definition: PluginBase.h:38