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

Documentation: README.md suggest a broken way to extend BaseLogger #256

Closed
BenceSzalai opened this issue Aug 8, 2023 · 7 comments
Closed
Labels
bug Something isn't working

Comments

@BenceSzalai
Copy link

BenceSzalai commented Aug 8, 2023

Describe the bug
The documentation here suggests to extend BaseLogger as:

export class CustomLogger<LogObj> extends BaseLogger<LogObj> {
  constructor(settings?: ISettingsParam<LogObj>, logObj?: LogObj) {
    super(settings, logObj, 5); // not valid any more
  }
}

However since v4.8.3 constructor of BaseLogger was changed to include a new first parameter runtime.

What is the recommended way to extend the logger now?

@BenceSzalai BenceSzalai added the bug Something isn't working label Aug 8, 2023
@BenceSzalai
Copy link
Author

I guess the README could be upgraded to:

import { BaseLogger, Runtime } from 'tslog'

export class CustomLogger<LogObj> extends BaseLogger<LogObj> {
  constructor(settings?: ISettingsParam<LogObj>, logObj?: LogObj) {
    super(Runtime, settings, logObj, 5);
  }
}

@BenceSzalai
Copy link
Author

BenceSzalai commented Aug 8, 2023

Also this part is broken now:

  public custom(...args: unknown[]): LogObj & ILogObjMeta {
    return super.log(8, "CUSTOM", ...args);
  }

because BaseLogger log method is declared to have a return type of (LogObj & ILogObjMeta) | undefined instead of LogObj & ILogObjMeta since 7f0670e#diff-94d248e9814c5047f571ddc28ee1895f22e9a8243907cf67066a4265c9858e71 .

@terehov
Copy link
Contributor

terehov commented Aug 8, 2023

Thank you for pointing this out. You're right. I'll update the docs.

terehov added a commit that referenced this issue Aug 8, 2023
@terehov
Copy link
Contributor

terehov commented Aug 8, 2023

To be honest, it shouldn't have happened, especially since it was just a minor update. I must have overlooked that during a PR merge. Sorry about that.
I moved the runtime into the BaseLogger, so the API can remain the same. I will release a patch shortly.

@terehov
Copy link
Contributor

terehov commented Aug 8, 2023

Solved in V4.9.1.

@terehov terehov closed this as completed Aug 8, 2023
@BenceSzalai
Copy link
Author

Probably should have opened a separate issue, but I thought both were about updateing documentation. So the part about public custom(...args: unknown[]): LogObj & ILogObjMeta { is still invalid.

terehov added a commit that referenced this issue Aug 8, 2023
@terehov
Copy link
Contributor

terehov commented Aug 8, 2023

Thank you, I updated the docs:

https://github.com/fullstack-build/tslog#custom-log-level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants