-
Notifications
You must be signed in to change notification settings - Fork 154
Feature request: export LoggerInterface in @aws-lambda-powertools/logger/types
#2828
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
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hi @sandrokeil - thank you for opening the issue. Could you please share a bit more about the use case for having the |
@dreamorosi I want to create a logger class which implements the Any concerns about to export the
|
Hey, thanks for the additional info. I don't have any major concern with exposing the interface, I'm only curious to learn how you'd use it. I remember removing it from the exported types because I though having the actual class would be enough to extend the behavior, for example: import { Logger } from "@aws-lambda-powertools/logger"
class MyLogger extends Logger {} By using the interface with import type { LoggerInterface } from "@aws-lambda-powertools/logger/types"
class MyLogger implements LoggerInterface {} Am I misunderstanding the intent? I would really appreciate if you could share a concrete code example, even if it's pseudo code. |
Either way - based on our definition of bug this should be classified as a feature request, since it doesn't have an impact on the runtime behavior of the tool. I'm going to change the type to |
@aws-lambda-powertools/logger/types
A public IMHO: I would mark the import type { LoggerInterface } from "@aws-lambda-powertools/logger/types"
export class MyEnchancedLogger implements LoggerInterface {
constructor (
private readonly logger: LoggerInterface
) {}
private handle(...) {
// more or less same logic like in PHPs FingersCrossed Logger
}
debug(input, ...extraInput): void {
this.handle(input, extraInput);
}
// same implementation for the other logging error level methods
addContext(context): void {
this.logger.addContext(context)
}
// same implementation for the rest of the LoggerInterface methods
} |
I see, thank you for taking the time to explain and share an example. With this in mind, I think it can make sense to export the interface again. I'm going to move onto your PR and leave any further comments there. |
This issue is now closed. Please be mindful that future comments are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so. |
This is now released under v2.6.0 version! |
Expected Behavior
The
LoggerInterface
should be able to be imported, so I can decorate the logger with my own implementation.Current Behavior
The current export of logger types is missing the
LoggerInterface
fromLogger.d.ts
. Seepowertools-lambda-typescript/packages/logger/src/types/index.ts
Lines 9 to 18 in 72803e2
Code snippet
Steps to Reproduce
LoggerInterface
Possible Solution
Export also
LoggerInterface
herepowertools-lambda-typescript/packages/logger/src/types/index.ts
Lines 9 to 18 in 72803e2
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
20.x
Packaging format used
npm
Execution logs
No response
The text was updated successfully, but these errors were encountered: