Skip to content

Commit c20058e

Browse files
use lazy logging
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 94d951e commit c20058e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/databricks/sql/backend/thrift_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ def cancel_command(self, command_id: CommandId) -> None:
12291229
if not thrift_handle:
12301230
raise ValueError("Not a valid Thrift command ID")
12311231

1232-
logger.debug("Cancelling command {}".format(command_id.to_hex_guid()))
1232+
logger.debug("Cancelling command %s", command_id.to_hex_guid())
12331233
req = ttypes.TCancelOperationReq(thrift_handle)
12341234
self.make_request(self._client.CancelOperation, req)
12351235

src/databricks/sql/backend/utils/guid_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ def guid_to_hex_id(guid: bytes) -> str:
1818
try:
1919
this_uuid = uuid.UUID(bytes=guid)
2020
except Exception as e:
21-
logger.debug(f"Unable to convert bytes to UUID: {guid!r} -- {str(e)}")
21+
logger.debug("Unable to convert bytes to UUID: %r -- %s", guid, str(e))
2222
return str(guid)
2323
return str(this_uuid)

src/databricks/sql/session.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def open(self):
9595
)
9696
self.protocol_version = self.get_protocol_version(self._session_id)
9797
self.is_open = True
98-
logger.info("Successfully opened session " + str(self.get_id_hex()))
98+
logger.info("Successfully opened session %s", str(self.get_id_hex()))
9999

100100
@staticmethod
101101
def get_protocol_version(session_id: SessionId):
@@ -125,7 +125,7 @@ def get_id_hex(self) -> str:
125125

126126
def close(self) -> None:
127127
"""Close the underlying session."""
128-
logger.info(f"Closing session {self.get_id_hex()}")
128+
logger.info("Closing session %s", self.get_id_hex())
129129
if not self.is_open:
130130
logger.debug("Session appears to have been closed already")
131131
return
@@ -138,13 +138,13 @@ def close(self) -> None:
138138
except DatabaseError as e:
139139
if "Invalid SessionHandle" in str(e):
140140
logger.warning(
141-
f"Attempted to close session that was already closed: {e}"
141+
"Attempted to close session that was already closed: %s", e
142142
)
143143
else:
144144
logger.warning(
145-
f"Attempt to close session raised an exception at the server: {e}"
145+
"Attempt to close session raised an exception at the server: %s", e
146146
)
147147
except Exception as e:
148-
logger.error(f"Attempt to close session raised a local exception: {e}")
148+
logger.error("Attempt to close session raised a local exception: %s", e)
149149

150150
self.is_open = False

0 commit comments

Comments
 (0)