Skip to content

Commit

Permalink
task callsites: part 2 (#4188)
Browse files Browse the repository at this point in the history
* add struct logging to docs serve

* remove merge fluff

* struct logging to seed command

* converting print to use structured logging

* more structured logging print conversion

* pulling apart formatting more

* added struct logging by disecting printer.py

* add struct logging to runnable

* add struct logging to task init

* fixed formatting

* more formatting and moving things around
  • Loading branch information
emmyoop authored and Nathaniel May committed Nov 9, 2021
1 parent 13f31ae commit 3cafc9e
Show file tree
Hide file tree
Showing 12 changed files with 1,049 additions and 377 deletions.
35 changes: 35 additions & 0 deletions core/dbt/events/format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import dbt.logger as logger # type: ignore # TODO eventually remove dependency on this logger
from dbt import ui
from typing import Optional


def format_fancy_output_line(
msg: str, status: str, index: Optional[int],
total: Optional[int], execution_time: Optional[float] = None,
truncate: bool = False
) -> str:
if index is None or total is None:
progress = ''
else:
progress = '{} of {} '.format(index, total)
# TODO: remove this formatting once we rip out all the old logger
prefix = "{timestamp} | {progress}{message}".format(
timestamp=logger.get_timestamp(),
progress=progress,
message=msg)

truncate_width = ui.printer_width() - 3
justified = prefix.ljust(ui.printer_width(), ".")
if truncate and len(justified) > truncate_width:
justified = justified[:truncate_width] + '...'

if execution_time is None:
status_time = ""
else:
status_time = " in {execution_time:0.2f}s".format(
execution_time=execution_time)

output = "{justified} [{status}{status_time}]".format(
justified=justified, status=status, status_time=status_time)

return output
Loading

0 comments on commit 3cafc9e

Please sign in to comment.