Writes an error to the Pine Logs panel and lets the script keep running, unlike runtime.error.
log.error(message) adds a line at the error level. log.error(formatString, arg0, arg1, ...) fills {0}, {1} and so on in the format string with the arguments. The script is not stopped.
Use it to report a failed check while still returning a usable result, for example logging a bad input and falling back to a default. When the script cannot continue, call runtime.error instead.
Syntax
log.error(message: series string) -> void
log.error(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
- The log line carries the bar it was written on, so you can find the first bar where a condition failed.
Example
//@version=6
indicator("Length check")
len = input.int(20, "Length")
safe = len < 2 ? 2 : len
if barstate.isfirst and len < 2
log.error("Length {0} is too small, using 2", len)
plot(ta.sma(close, safe), "SMA", color.blue)See also
Runs on Sidechair