Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding stream metadata types to pino.d.ts #1557

Closed
segevfiner opened this issue Sep 13, 2022 · 4 comments · Fixed by #1566
Closed

Consider adding stream metadata types to pino.d.ts #1557

segevfiner opened this issue Sep 13, 2022 · 4 comments · Fixed by #1566

Comments

@segevfiner
Copy link
Contributor

e.g.

const metadata = Symbol.for("pino.metadata");

export interface DestinationStreamMetadata {
  [metadata]?: boolean;
  lastLevel?: number;
  lastTime?: string;
  lastMsg?: string;
  lastObj?: object;
  lastLogger?: pino.Logger;
}

Though using discriminated union type narrowing might make for a better type:

const metadata = Symbol.for("pino.metadata");

interface DestinationStreamHasMetadata {
  [metadata]: true;
  lastLevel: number;
  lastTime: string;
  lastMsg: string;
  lastObj: object;
  lastLogger: pino.Logger;
}

export type DestinationStreamMetadata = { [metadata]?: boolean } | DestinationStreamHasMetadata;
@mcollina
Copy link
Member

Note that I hope to remove all of those in a upcoming major. Those were a hack to support the old pretty print option.

@segevfiner
Copy link
Contributor Author

The builtin multistream also uses this. What API would they be replaced with?

@mcollina
Copy link
Member

Ah. I forgot about that one. I guess they are here to stay for one more cycle then. Would you like to send a PR to add the types?

segevfiner added a commit to segevfiner/pino that referenced this issue Sep 26, 2022
mcollina pushed a commit that referenced this issue Oct 6, 2022
* Add DestinationStreamMetadata type to pino.d.ts

Fixes #1557

* Use symbols.needsMetadataGsym instead

* Improve DestinationStreamWithMetadata type

* Fix tsd weirdness
@github-actions
Copy link

github-actions bot commented Nov 6, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants