fix: make `%ex` behavior context-independent (#3919)
Historically, throwable pattern converters (`%ex`, `%xEx`, etc.) behaved in a context-sensitive way:
* If the **preceding formatter’s expansion** did not end with whitespace, the converter automatically inserted a space before rendering the exception.
In version `2.25.0`, this was changed to insert a **newline** instead of a space, but the behavior was still dependent on surrounding context.
#### What this change does
This PR removes the context-dependent behavior altogether and makes `%ex` expansion fully predictable, while remaining backward-compatible:
* When `%ex` is **added implicitly** because `alwaysWriteExceptions=true`:
* If the pattern already ends with `%n`, a plain `%ex` is appended.
* Otherwise, `%notEmpty{%n%ex}` is appended.
This ensures exceptions are always clearly separated from the main log message by a newline, without adding extra characters when no exception is present.
* When `%ex` is **explicitly included** in the pattern by the user:
* Its expansion is rendered exactly as written in the pattern.
* It will **never** prepend a newline on its own.
#### Why
* Eliminates confusing context-sensitive behavior.
* Makes output consistent and predictable.
* Preserves legacy expectations by only modifying implicitly added `%ex`.
Closes #3873
Co-authored-by: Volkan Yazıcı <volkan@yazi.ci>
12 files changed