-
Notifications
You must be signed in to change notification settings - Fork 451
Expand file tree
/
Copy pathlog_lsp_event.py
More file actions
62 lines (52 loc) · 1.96 KB
/
log_lsp_event.py
File metadata and controls
62 lines (52 loc) · 1.96 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# pyre-strict
"""
This module provides shared logic for logging events - mainly
error information - in Pyre language servers (whenever telemetry is
enabled, which it is not by default in open-source Pyre).
Be default these logs go to the table pyre_lsp_events.
Note that this Pyre-side logging is distinct from editor-handled language
server telemetry, which (when enabled) is accomplished by sending special
json messages to the editor, which is responsible for loggign them.
"""
import enum
from typing import Dict, Optional
from . import backend_arguments, remote_logger, version
class LSPEvent(enum.Enum):
INITIALIZED = "initialized"
NOT_INITIALIZED = "not initialized"
CONNECTED = "connected"
NOT_CONNECTED = "not connected"
NOT_CONFIGURED = "not configured"
DISCONNECTED = "disconnected"
SUSPENDED = "suspended"
STOPPED = "stopped"
COVERED = "covered"
def log(
remote_logging: Optional[backend_arguments.RemoteLogging],
event: LSPEvent,
integers: Optional[Dict[str, int]] = None,
normals: Optional[Dict[str, Optional[str]]] = None,
) -> None:
if remote_logging is not None:
logger = remote_logging.logger
if logger is not None:
log_identifier = remote_logging.identifier
remote_logger.log(
category=remote_logger.LoggerCategory.LSP_EVENTS,
logger=logger,
integers=integers,
normals={
**(normals or {}),
"event": event.value,
"pyre client version": version.__version__,
**(
{"identifier": log_identifier}
if log_identifier is not None
else {}
),
},
)