]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_log.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
6 #include <boost/container/flat_map.hpp>
7 #include "rgw_common.h"
8 #include "common/Formatter.h"
9 #include "common/OutputDataSocket.h"
13 struct rgw_log_entry
{
15 using headers_map
= boost::container::flat_map
<std::string
, std::string
>;
16 using Clock
= req_state::Clock
;
18 rgw_user object_owner
;
19 rgw_user bucket_owner
;
21 Clock::time_point time
;
30 uint64_t bytes_received
;
32 Clock::duration total_time
;
36 headers_map x_headers
;
38 void encode(bufferlist
&bl
) const {
39 ENCODE_START(9, 5, bl
);
40 encode(object_owner
.id
, bl
);
41 encode(bucket_owner
.id
, bl
);
44 encode(remote_addr
, bl
);
49 encode(http_status
, bl
);
50 encode(error_code
, bl
);
51 encode(bytes_sent
, bl
);
53 encode(total_time
, bl
);
54 encode(user_agent
, bl
);
56 encode(bytes_received
, bl
);
57 encode(bucket_id
, bl
);
59 encode(object_owner
, bl
);
60 encode(bucket_owner
, bl
);
61 encode(x_headers
, bl
);
64 void decode(bufferlist::const_iterator
&p
) {
65 DECODE_START_LEGACY_COMPAT_LEN(8, 5, 5, p
);
66 decode(object_owner
.id
, p
);
68 decode(bucket_owner
.id
, p
);
71 decode(remote_addr
, p
);
76 decode(http_status
, p
);
77 decode(error_code
, p
);
78 decode(bytes_sent
, p
);
80 decode(total_time
, p
);
81 decode(user_agent
, p
);
84 decode(bytes_received
, p
);
93 snprintf(buf
, sizeof(buf
), "%" PRIu64
, id
);
105 decode(object_owner
, p
);
106 decode(bucket_owner
, p
);
109 decode(x_headers
, p
);
113 void dump(Formatter
*f
) const;
114 static void generate_test_instances(list
<rgw_log_entry
*>& o
);
116 WRITE_CLASS_ENCODER(rgw_log_entry
)
118 class OpsLogSocket
: public OutputDataSocket
{
119 Formatter
*formatter
;
122 void formatter_to_bl(bufferlist
& bl
);
125 void init_connection(bufferlist
& bl
) override
;
128 OpsLogSocket(CephContext
*cct
, uint64_t _backlog
);
129 ~OpsLogSocket() override
;
131 void log(struct rgw_log_entry
& entry
);
136 int rgw_log_op(RGWRados
*store
, RGWREST
* const rest
, struct req_state
*s
,
137 const string
& op_name
, OpsLogSocket
*olog
);
138 void rgw_log_usage_init(CephContext
*cct
, RGWRados
*store
);
139 void rgw_log_usage_finalize();
140 void rgw_format_ops_log_entry(struct rgw_log_entry
& entry
,
141 Formatter
*formatter
);
143 #endif /* CEPH_RGW_LOG_H */