Dobby 3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Loading...
Searching...
No Matches
FileSink.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 2022 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#pragma once
21
22#include "ILoggingSink.h"
23
24class FileSink : public ILoggingSink
25{
26public:
27 FileSink(const std::string &containerId, std::shared_ptr<rt_dobby_schema> &containerConfig);
28
29 ~FileSink();
30
31public:
32 void DumpLog(const int bufferFd) override;
33
34 void process(const std::shared_ptr<AICommon::IPollLoop> &pollLoop, epoll_event event) override;
35
36private:
37 int openFile(const std::string& pathName);
38
39private:
40 const std::shared_ptr<rt_dobby_schema> mContainerConfig;
41 const std::string mContainerId;
42
43 ssize_t mFileSizeLimit;
44 std::string mOutputFilePath;
45 int mOutputFileFd;
46 int mDevNullFd;
47
48 bool mLimitHit;
49 char mBuf[PTY_BUFFER_SIZE];
50
51 std::mutex mLock;
52};
Definition FileSink.h:25
void DumpLog(const int bufferFd) override
Reads all the available data from the provided fd and writes it to the output file....
Definition FileSink.cpp:114
int openFile(const std::string &pathName)
Opens the log file at a given path. Will create a new file when called, and subsequent writes will ap...
Definition FileSink.cpp:245
void process(const std::shared_ptr< AICommon::IPollLoop > &pollLoop, epoll_event event) override
Called by the pollLoop when an event occurs on the container ptty.
Definition FileSink.cpp:171
Definition ILoggingSink.h:29