Skip to content

Commit a089705

Browse files
committed
Add posit.sdk logger
1 parent 4c9294a commit a089705

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/posit/connect/external/databricks.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
POSIT_LOCAL_CLIENT_CREDENTIALS_AUTH_TYPE = "posit-local-client-credentials"
3232
POSIT_WORKBENCH_AUTH_TYPE = "posit-workbench"
3333

34+
logger = logging.getLogger("posit.sdk")
3435

3536
def _new_bearer_authorization_header(credentials: Credentials) -> Dict[str, str]:
3637
"""Helper to transform an Credentials object into the Bearer auth header consumed by databricks.
@@ -119,8 +120,8 @@ def __init__(
119120
self._client = client
120121
self._user_session_token = user_session_token
121122
if self._user_session_token is None:
122-
logging.info(
123-
"ConnectStrategy will attempt to use OAuth Service Account credentials because user_session_token is not set."
123+
logger.info(
124+
"ConnectStrategy will attempt to use OAuth Service Account credentials because user_session_token is not set"
124125
)
125126

126127
def auth_type(self) -> str:
@@ -129,7 +130,7 @@ def auth_type(self) -> str:
129130
def __call__(self, *args, **kwargs) -> CredentialsProvider: # noqa: ARG002
130131
if not is_connect():
131132
raise ValueError(
132-
"The ConnectStrategy is not supported for content running outside of Posit Connect."
133+
"ConnectStrategy is not supported for content running outside of Posit Connect"
133134
)
134135

135136
if self._client is None:
@@ -172,24 +173,24 @@ def new_config(
172173
del kwargs["credentials_strategy"]
173174

174175
if is_connect():
175-
logging.info(
176-
"Initializing ConnectStrategy because the content appears to be running on Posit Connect."
176+
logger.info(
177+
"Initializing ConnectStrategy because the content appears to be running on Posit Connect"
177178
)
178179
if posit_connect_strategy is not None:
179180
credentials_strategy = posit_connect_strategy
180181
else:
181182
credentials_strategy = ConnectStrategy()
182183
elif is_workbench():
183-
logging.info(
184-
"Initializing WorkbenchStrategy because the content appears to be running on Posit Workbench."
184+
logger.info(
185+
"Initializing WorkbenchStrategy because the content appears to be running on Posit Workbench"
185186
)
186187
if posit_workbench_strategy is not None:
187188
credentials_strategy = posit_workbench_strategy
188189
else:
189190
credentials_strategy = WorkbenchStrategy()
190191
else:
191-
logging.info(
192-
"Initializing default strategy because neither Posit Connect nor Posit Workbench were detected."
192+
logger.info(
193+
"Initializing default strategy because neither Posit Connect nor Posit Workbench were detected"
193194
)
194195
if posit_default_strategy is not None:
195196
credentials_strategy = posit_default_strategy

0 commit comments

Comments
 (0)