Skip to content

Commit

Permalink
Update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
wsargent committed Dec 26, 2024
1 parent 640b9eb commit b435832
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 4.0.0

* Change package from `com.tersesystems.echopraxia` to `echopraxia`.
* Move logging specific API (Conditions, LoggingContext) to `echopraxia.logging.api` so that only fields, values, attributes are core `echopraxia.api`. * Break out JSONPath dependency (requires SLF4J 2.x, awkward for Log4J2 and JUL frameworks)
* Add `JSONPathCondition.pathCondition` so that JSON path functionality is still available.
* Add a `simple` logger that does not use field builder functions or conditions.
* Remove `async`, `fluent`, and `semantic` modules from codebase (they are best done at user level)
* Remove `asyncLog` methods from core loggers (this is better done at a user level).
* Update logstash encoder dependency to 8.0, logback dependency to 1.5.x (requires SLF4J 2.x)
* Add dependency on jsonpath for `scripting` module.
* Remove deprecated methods on field attributes.

## 3.2.1

* Fix a bug where `toStringValue` was not correctly applied to `Value.object` or `Value.array`.
Expand Down
14 changes: 9 additions & 5 deletions docs/usage/conditions.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ This is only a part of the available functionality in conditions. You can tie c

## JSON Path

If you are using the Logstash implementation, you can use the `echopraxia.jsonpath.JsonPathCondition.pathCondition()` method to provide you with an extended context that has logging methods:
If you are using the Logstash implementation or have explicitly added the `jsonpath` module, you can use the `echopraxia.jsonpath.JsonPathCondition.pathCondition()` method to provide you with an extended context that has logging methods:

This will give you a context that extends `FindPathMethods` that will let you use [JSONPath](https://github.com/json-path/JsonPath#jayway-jsonpath) to find values from the logging context in a condition.

```java
import static echopraxia.jsonpath.JsonPathCondition.*;

Condition fooCondition = pathCondition((level, ctx) ->
ctx.findString("$.foo").filter(s -> s.equals("bar")).isPresent()
);
Expand Down Expand Up @@ -127,20 +129,22 @@ List<String> interests = context.findList("$.person.mother.interests");
You can use [inline predicates](https://github.com/json-path/JsonPath#inline-predicates), which will return a `List` of the results:

```java
final Condition cheapBookCondition =
(level, context) -> ! context.findList("$.store.book[?(@.price < 10)]").isEmpty();
final Condition cheapBookCondition = pathCondition(
(level, context) -> ! context.findList("$.store.book[?(@.price < 10)]").isEmpty());
```

The inline and filter predicates are not available for exceptions. Instead, you must use `filter`:

```java
import static echopraxia.jsonpath.JsonPathCondition.*;

class FindException {
void logException() {
Condition throwableCondition = json
Condition throwableCondition = pathCondition(
(level, ctx) ->
ctx.findThrowable()
.filter(e -> "test message".equals(e.getMessage()))
.isPresent();
.isPresent());

logger.error(throwableCondition, "Error message", new RuntimeException("test message"));
}
Expand Down

0 comments on commit b435832

Please sign in to comment.