Closed DanielSRS closed 1 month ago
@DanielSRS Wow, awesome job! I’m testing all the code, and there’s a modification to make in the fileAsyncTransport regarding the method checks, but really great work. To complete it, do you have any ideas on how to retrieve the levels types directly from the configuration instead of setting them manually?
@alessandro-bottamedi Just added it
Now instead of doing:
const config = {
levels: {
trace: 0,
info: 1,
error: 2,
},
};
var log = logger.createLogger<"trace" | "info" | "error">(config);
Providing the config should be enough. If not config is provided, the default ones are used instead
const config = {
levels: {
trace: 0,
info: 1,
error: 2,
},
} as const;
var log = logger.createLogger(config);
log.trace // should be correctly typed
var defaultLog = logger.createLogger();
defaultLog.warn // also correctly typed
This PR aims to improve type checking, mostly when setting a transport function.
The most notable change in this PR is that transportFunctionType is now a generic type, to when previously creating a custom transport could be done like this:
will now be like this: