aboutsummaryrefslogtreecommitdiffstats
path: root/vespalog/src/vespa/log/log_message.h
blob: 6966ad04f742f47b7fb8d4ac6d179326dc8c02d6 (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
46
47
48
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "log.h"
#include <string_view>
#include <string>

namespace ns_log {

/*
 * Class containing a log message.
 */
class LogMessage {
    int64_t          _time_nanos;
    std::string      _hostname;
    int32_t          _process_id;
    int32_t          _thread_id;
    std::string      _service;
    std::string      _component;
    Logger::LogLevel _level;
    std::string      _payload;

public:
    LogMessage();
    LogMessage(LogMessage &&) noexcept;
    LogMessage & operator=(LogMessage &&) noexcept;
    LogMessage(int64_t time_nanos_in,
               const std::string& hostname_in,
               int32_t process_id_in,
               int32_t thread_id_in,
               const std::string& service_in,
               const std::string& component_in,
               Logger::LogLevel level_in,
               const std::string& payload_in);
    ~LogMessage();
    void parse_log_line(std::string_view log_line);
    int64_t           time_nanos() const { return _time_nanos; }
    const std::string  &hostname() const { return _hostname; }
    int32_t           process_id() const { return _process_id; }
    int32_t            thread_id() const { return _thread_id; }
    const std::string   &service() const { return _service;}
    const std::string &component() const { return _component; }
    Logger::LogLevel       level() const { return _level; }
    const std::string   &payload() const { return _payload; }
};

}