]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/controllers/logs.py
1 # -*- coding: utf-8 -*-
2 from __future__
import absolute_import
6 from ..security
import Scope
7 from ..services
.ceph_service
import CephService
8 from ..tools
import NotificationQueue
9 from . import APIDoc
, APIRouter
, BaseController
, Endpoint
, EndpointDoc
, ReadPermission
21 "addr": (str, "IP Address"),
28 "priority": (str, ""),
34 @APIRouter('/logs', Scope
.LOG
)
35 @APIDoc("Logs Management API", "Logs")
36 class Logs(BaseController
):
39 self
._log
_initialized
= False
40 self
.log_buffer
= collections
.deque(maxlen
=LOG_BUFFER_SIZE
)
41 self
.audit_buffer
= collections
.deque(maxlen
=LOG_BUFFER_SIZE
)
43 def append_log(self
, log_struct
):
44 if log_struct
['channel'] == 'audit':
45 self
.audit_buffer
.appendleft(log_struct
)
47 self
.log_buffer
.appendleft(log_struct
)
49 def load_buffer(self
, buf
, channel_name
):
50 lines
= CephService
.send_command(
51 'mon', 'log last', channel
=channel_name
, num
=LOG_BUFFER_SIZE
, level
='debug')
55 def initialize_buffers(self
):
56 if not self
._log
_initialized
:
57 self
._log
_initialized
= True
59 self
.load_buffer(self
.log_buffer
, 'cluster')
60 self
.load_buffer(self
.audit_buffer
, 'audit')
62 NotificationQueue
.register(self
.append_log
, 'clog')
66 @EndpointDoc("Display Logs Configuration",
67 responses
={200: LOGS_SCHEMA
})
69 self
.initialize_buffers()
71 clog
=list(self
.log_buffer
),
72 audit_log
=list(self
.audit_buffer
),