mirror of
https://github.com/strapi/strapi.git
synced 2025-09-03 05:39:36 +00:00
diagnostics
This commit is contained in:
parent
b6a7792d8f
commit
a58a2f9a51
@ -197,9 +197,27 @@ The following events are available:
|
|||||||
|
|
||||||
### Diagnostics events
|
### Diagnostics events
|
||||||
|
|
||||||
`engine.diagnostics.onDiagnostic(formatDiagnostic('export'));`
|
The engine includes a diagnostics reporter which can be used to listen for diagnostics information (debug messages, errors, etc).
|
||||||
|
|
||||||
**TODO**
|
Here is an example for creating a diagnostics listener:
|
||||||
|
|
||||||
|
```
|
||||||
|
// your listener
|
||||||
|
engine.diagnostics.onDiagnostic(async (data: GenericDiagnostic) => {
|
||||||
|
// handle the diagnostics, for example with custom logging
|
||||||
|
});
|
||||||
|
|
||||||
|
// engine/diagnostics.ts - format of the data sent to the listener
|
||||||
|
export type GenericDiagnostic<K extends DiagnosticKind, T = unknown> = {
|
||||||
|
kind: K;
|
||||||
|
details: {
|
||||||
|
message: string;
|
||||||
|
createdAt: Date;
|
||||||
|
} & T;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type DiagnosticKind = 'error' | 'warning' | 'info';
|
||||||
|
```
|
||||||
|
|
||||||
### Transforms
|
### Transforms
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ export type GenericDiagnostic<K extends DiagnosticKind, T = unknown> = {
|
|||||||
export type DiagnosticKind = 'error' | 'warning' | 'info';
|
export type DiagnosticKind = 'error' | 'warning' | 'info';
|
||||||
|
|
||||||
export type DiagnosticListener<T extends DiagnosticKind = DiagnosticKind> = (
|
export type DiagnosticListener<T extends DiagnosticKind = DiagnosticKind> = (
|
||||||
diagnostic: { kind: T } & Diagnostic extends infer U ? U : 'foo'
|
diagnostic: { kind: T } & Diagnostic extends infer U ? U : never
|
||||||
) => void | Promise<void>;
|
) => void | Promise<void>;
|
||||||
|
|
||||||
export type DiagnosticEvent = 'diagnostic' | `diagnostic.${DiagnosticKind}`;
|
export type DiagnosticEvent = 'diagnostic' | `diagnostic.${DiagnosticKind}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user