summaryrefslogtreecommitdiffstats
path: root/logd/src/logd/conf.h
blob: ce135d153cd056f758716b8b0179ab0ceb7e1a4e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <logd/config-logd.h>
#include <vespa/config/config.h>

namespace logdemon {

class ConfSub {
private:
    char _logServer[256];
    int _logPort;
    int _logserverfd;
    int _rotate_size;
    int _rotate_age;
    int _remove_meg;
    int _remove_age;
    bool _use_logserver;
    Forwarder& _fw;
    config::ConfigSubscriber _subscriber;
    config::ConfigHandle<cloud::config::log::LogdConfig>::UP _handle;
    bool _newConf;

    void connectToLogserver();
    void connectToDevNull();
    void resetFileDescriptor(int newfd);
    ConfSub(const ConfSub& other);
    ConfSub& operator=(const ConfSub& other);
public:
    void latch();
    void closeConn();
    ConfSub(Forwarder &fw, const config::ConfigUri & configUri);
    ~ConfSub();

    int getservfd() const { return _logserverfd; }
    int getRotateSize() const { return _rotate_size; }
    int getRotateAge() const { return _rotate_age; }
    int getRemoveMegabytes() const { return _remove_meg; }
    int getRemoveAge() const { return _remove_age; }
    bool useLogserver() const { return _use_logserver; }

    void configure(std::unique_ptr<cloud::config::log::LogdConfig> cfg);
};

} // namespace