Skip to content

Commit

Permalink
Merge branch 'patch-1' of git://github.com/RadiationSickness/ajv into…
Browse files Browse the repository at this point in the history
… RadiationSickness-patch-1
  • Loading branch information
epoberezkin committed Feb 22, 2020
2 parents 8fd1e44 + 367527c commit 52adde5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,30 @@ Properties of `params` object in errors depend on the keyword that failed valida
- custom keywords (in case keyword definition doesn't create errors) - property `keyword` (the keyword name).


### Error Logging

Using the `logger` option when initiallizing Ajv will allow you to define custom logging. Here you can build upon the exisiting logging. The use of other logging packages is supported as long as the package or its associated wrapper exposes the required methods. If any of the required methods are missing an exception will be thrown.
- **Required Methods**: `log`, `warn`, `error`

```javascript
var otherLogger = new OtherLogger();
var ajv = new Ajv({
logger: {
log: function log(_log) {
return console.log(_log);
},
warn: function warn(_warn) {
return otherLogger.logWarn(_warn);
},
error: function error(_error) {
otherLogger.logError(_error);
return console.error(_error);
}
}
});
```


## Plugins

Ajv can be extended with plugins that add custom keywords, formats or functions to process generated code. When such plugin is published as npm package it is recommended that it follows these conventions:
Expand Down

0 comments on commit 52adde5

Please sign in to comment.