Skip to content

Commit

Permalink
fix: adjust data type for some plugin interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
theogravity committed Sep 8, 2024
1 parent 38d7135 commit 14f4ce1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .changeset/stupid-bears-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"loglayer": minor
---

Change messages property of ShouldSendToLoggerParams and PluginBeforeMessageOutParams to `any` from `MessageDataType`.
This allows for more flexibility in the messages property of these params since external libraries may feed in different types of data.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -957,11 +957,11 @@ export interface PluginBeforeMessageOutParams {
/**
* Message data that is copied from the original.
*/
messages: MessageDataType[];
messages: any[];
}
```

`onBeforeMessageOut(params: PluginOnBeforeMessageOutParams) => MessageDataType[]`
`onBeforeMessageOut(params: PluginOnBeforeMessageOutParams) => any[]`

Called after `onBeforeDataOut` and before `shouldSendToLogger`.
This allows you to modify the message data before it is sent to the destination logging library.
Expand Down Expand Up @@ -1007,7 +1007,7 @@ export interface PluginShouldSendToLoggerParams {
/**
* Message data that is copied from the original.
*/
messages: MessageDataType[];
messages: any[];
/**
* Log level of the message
*/
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/types/plugins.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface PluginShouldSendToLoggerParams {
/**
* Message data that is copied from the original.
*/
messages: MessageDataType[];
messages: any[];
/**
* Log level of the message
*/
Expand All @@ -40,10 +40,10 @@ export interface PluginBeforeMessageOutParams {
/**
* Message data that is copied from the original.
*/
messages: MessageDataType[];
messages: any[];
}

export type PluginBeforeMessageOutFn = (params: PluginBeforeMessageOutParams) => MessageDataType[];
export type PluginBeforeMessageOutFn = (params: PluginBeforeMessageOutParams) => any[];

export type PluginOnMetadataCalledFn = (metadata: Record<string, any>) => Record<string, any> | null | undefined;

Expand Down Expand Up @@ -79,7 +79,7 @@ export interface LogLayerPlugin {
*
* @returns [Array] The message data to be sent to the destination logging library.
*/
onBeforeMessageOut?(params: PluginBeforeMessageOutParams): MessageDataType[] | null | undefined;
onBeforeMessageOut?(params: PluginBeforeMessageOutParams): any[];

/**
* Called before the data is sent to the logger. Return false to omit sending
Expand Down

0 comments on commit 14f4ce1

Please sign in to comment.