Skip to content

Commit 389eabd

Browse files
authored
Merge pull request PrefectHQ#3179 from PrefectHQ/logs-updates
Logging updates
2 parents 8e7b048 + 1cc0e36 commit 389eabd

File tree

19 files changed

+77
-22
lines changed

19 files changed

+77
-22
lines changed

changes/pr3179.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
enhancement:
2+
- "Cloud logger now responds to logging level - [#3179](https://github.com/PrefectHQ/prefect/pull/3179)"
3+
4+
breaking:
5+
- "Logging level in Cloud now defaults to INFO - [#3179](https://github.com/PrefectHQ/prefect/pull/3179)"

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ norecursedirs = *.egg-info .git .mypy_cache node_modules .pytest_cache .vscode
44
env =
55
SKIP_DOCKER_ENVIRONMENT_TESTS = True
66
PREFECT__USER_CONFIG_PATH=""
7+
PREFECT__BACKEND="cloud"
78
usedevelop = True
89

910
[isort]

src/prefect/agent/docker/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def populate_env_vars(self, flow_run: GraphQLResult) -> dict:
450450
"PREFECT__CONTEXT__FLOW_ID": flow_run.flow.id, # type: ignore
451451
"PREFECT__CLOUD__USE_LOCAL_SECRETS": "false",
452452
"PREFECT__LOGGING__LOG_TO_CLOUD": str(self.log_to_cloud).lower(),
453-
"PREFECT__LOGGING__LEVEL": "DEBUG",
453+
"PREFECT__LOGGING__LEVEL": config.logging.level,
454454
"PREFECT__ENGINE__FLOW_RUNNER__DEFAULT_CLASS": "prefect.engine.cloud.CloudFlowRunner",
455455
"PREFECT__ENGINE__TASK_RUNNER__DEFAULT_CLASS": "prefect.engine.cloud.CloudTaskRunner",
456456
**self.env_vars,

src/prefect/agent/fargate/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ def _create_task_definition(
604604
"name": "PREFECT__LOGGING__LOG_TO_CLOUD",
605605
"value": str(self.log_to_cloud).lower(),
606606
},
607-
{"name": "PREFECT__LOGGING__LEVEL", "value": "DEBUG"},
607+
{"name": "PREFECT__LOGGING__LEVEL", "value": config.logging.level},
608608
{
609609
"name": "PREFECT__ENGINE__FLOW_RUNNER__DEFAULT_CLASS",
610610
"value": "prefect.engine.cloud.CloudFlowRunner",

src/prefect/agent/kubernetes/agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ def replace_job_spec_yaml(self, flow_run: GraphQLResult, image: str) -> dict:
191191
env[4]["value"] = os.getenv("NAMESPACE", "default")
192192
env[5]["value"] = str(self.labels)
193193
env[6]["value"] = str(self.log_to_cloud).lower()
194+
env[7]["value"] = config.logging.level
194195

195196
# append all user provided values
196197
for key, value in self.env_vars.items():

src/prefect/agent/kubernetes/job_spec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ spec:
2929
value: PREFECT__CLOUD__AGENT__LABELS
3030
- name: PREFECT__LOGGING__LOG_TO_CLOUD
3131
value: PREFECT__LOGGING__LOG_TO_CLOUD
32+
- name: PREFECT__LOGGING__LEVEL
33+
value: "INFO"
3234
- name: PREFECT__CLOUD__USE_LOCAL_SECRETS
3335
value: "false"
34-
- name: PREFECT__LOGGING__LEVEL
35-
value: "DEBUG"
3636
- name: PREFECT__ENGINE__FLOW_RUNNER__DEFAULT_CLASS
3737
value: "prefect.engine.cloud.CloudFlowRunner"
3838
- name: PREFECT__ENGINE__TASK_RUNNER__DEFAULT_CLASS

src/prefect/agent/local/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def populate_env_vars(self, flow_run: GraphQLResult) -> dict:
191191
"PREFECT__CONTEXT__FLOW_ID": flow_run.flow.id, # type: ignore
192192
"PREFECT__CLOUD__USE_LOCAL_SECRETS": "false",
193193
"PREFECT__LOGGING__LOG_TO_CLOUD": str(self.log_to_cloud).lower(),
194-
"PREFECT__LOGGING__LEVEL": "DEBUG",
194+
"PREFECT__LOGGING__LEVEL": config.logging.level,
195195
"PREFECT__ENGINE__FLOW_RUNNER__DEFAULT_CLASS": "prefect.engine.cloud.CloudFlowRunner",
196196
"PREFECT__ENGINE__TASK_RUNNER__DEFAULT_CLASS": "prefect.engine.cloud.CloudTaskRunner",
197197
**self.env_vars,

src/prefect/engine/cloud/flow_runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def call_runner_target_handlers(self, old_state: State, new_state: State) -> Sta
112112
)
113113
except Exception as exc:
114114
msg = "Exception raised while calling state handlers: {}".format(repr(exc))
115-
self.logger.debug(msg)
115+
self.logger.exception(msg)
116116
if raise_on_exception:
117117
raise exc
118118
new_state = Failed(msg, result=exc)
@@ -143,7 +143,7 @@ def call_runner_target_handlers(self, old_state: State, new_state: State) -> Sta
143143
)
144144
new_state = state
145145
except Exception as exc:
146-
self.logger.debug(
146+
self.logger.exception(
147147
"Failed to set flow state with error: {}".format(repr(exc))
148148
)
149149
raise ENDRUN(state=new_state)
@@ -290,7 +290,7 @@ def run(
290290
time_remaining = max(
291291
(end_state.start_time - pendulum.now("utc")).total_seconds(), 0
292292
)
293-
self.logger.info(
293+
self.logger.debug(
294294
(
295295
f"Flow run is in a Queued state. Sleeping for at most {time_remaining:.2f} "
296296
f"seconds and attempting to run again."

src/prefect/engine/flow_runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ def set_flow_to_running(self, state: State) -> State:
347347
- ENDRUN: if the flow is not pending or running
348348
"""
349349
if state.is_pending():
350-
self.logger.info("Starting flow run.")
351350
return Running(message="Running flow.")
352351
elif state.is_running():
353352
return state

src/prefect/environments/execution/dask/job.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ spec:
4141
- name: PREFECT__LOGGING__LOG_TO_CLOUD
4242
value: "true"
4343
- name: PREFECT__LOGGING__LEVEL
44-
value: "DEBUG"
44+
value: "INFO"
4545
- name: PREFECT__DEBUG
4646
value: "true"
4747
- name: DASK_DISTRIBUTED__SCHEDULER__WORK_STEALING

0 commit comments

Comments
 (0)