Writes a warning to the Pine Logs panel, for something unexpected that the script can carry on through.
log.warning(message) adds a line at the warning level, which the log panel shows apart from plain information. log.warning(formatString, arg0, arg1, ...) fills {0}, {1} and so on in the format string with the arguments.
Reach for it when a value is odd but not fatal, such as a missing input or a fallback that was applied. Use log.error when something went wrong, and runtime.error to stop the script.
Syntax
log.warning(message: series string) -> void
log.warning(formatString: series string, arg0, arg1, ...: series int/float/bool/string/array<int/float/bool/string>) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| message | series string | required | The text written to the log. It is one string, so build it with str.tostring or str.format. |
| formatString | series string | required | Text containing placeholders {0}, {1} and so on, filled with the arguments that follow. |
| arg0 | series int/ | required | The value for {0} in the format string. |
| arg1 | series int/ | required | The value for {1} in the format string. |
| ... | series int/ | required | More values for {2}, {3} and so on. Numbers, bools, strings and arrays of them are accepted. |
Returns
Nothing.
Remarks
- Logging does not change what the script computes or plots. Guard a call on every bar with a condition so the log stays readable.
Example
//@version=6
indicator("Volume warning")
plot(close, "Close", color.blue)
if volume == 0
log.warning("No volume on bar {0}", bar_index)See also
Runs on Sidechair