Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update log.md #4111

Merged
merged 14 commits into from
Sep 26, 2023
29 changes: 28 additions & 1 deletion website/docs/reference/dbt-jinja-functions/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,34 @@ __Args__:

Logs a line to either the log file or stdout.

([Source on GitHub](https://github.com/dbt-labs/dbt-core/blob/HEAD/core/dbt/context/base.py#L432))
<details>
<summary>Code source</summary>
Refer to <a href="https://github.com/dbt-labs/dbt-core/blob/HEAD/core/dbt/context/base.py#L549-L566">GitHub</a> or the following code as a source: <br />
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved
<code>

def log(msg: str, info: bool = False) -> str:
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

"""Logs a line to either the log file or stdout.

:param msg: The message to log
:param info: If `False`, write to the log file. If `True`, write to
both the log file and stdout.

> macros/my_log_macro.sql

{% macro some_macro(arg1, arg2) %}
{{ log("Running some_macro: " ~ arg1 ~ ", " ~ arg2) }}
{% endmacro %}"
"""
if info:
fire_event(JinjaLogInfo(msg=msg, node_info=get_node_info()))
else:
fire_event(JinjaLogDebug(msg=msg, node_info=get_node_info()))
return ""

</code>

</details>

```sql

Expand Down