Skip to content

Using custom logger fails compilation due to version mismatch of the Logger #159

@derun-info

Description

@derun-info

When trying to plug in a custom logger from std/log this error happens.

function logger() {
    return log.getLogger("db");
}

await mysql.configLogger({logger:logger()});
error: TS2322 [ERROR]: Type 'import("https://deno.land/std@0.197.0/log/logger.ts").Logger' is not assignable to type 'import("https://deno.land/std@0.104.0/log/logger.ts").Logger'.
  Property '#level' in type 'Logger' refers to a different member that cannot be accessed from within type 'Logger'.
await mysql.configLogger({ logger: logger() });
                           ~~~~~~
    at file:///.../db.ts:8:28

    The expected type comes from property 'logger' which is declared here on type 'LoggerConfig'
      logger?: log.Logger;
      ~~~~~~
        at https://deno.land/x/mysql@v2.11.0/src/logger.ts:22:3

This parameter was not documented, but I assumed it was intended to be used like above. Is there a way to build it in some way that it is not so strict on the version incompatibility?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions