denodrivers / denodrivers/mysql

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

Open
#159 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
264
Forks
64
PR merge metrics
No merged PRs in 30d

Description

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

```typescript
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?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the TypeScript error with the std@0.197.0 logger and inspect src/logger.ts, especially the LoggerConfig declaration reported in the issue. Compare the logger versions used by the package and the application; done means the documented custom logger configuration compiles without the version-mismatch error.

Written by the indexing model from the issue text.

Assessment

Tech stack
deno, mysql, typescript
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.