rescript-logger
rescript-logger copied to clipboard
Bug: @log does not work on cases prefixed with module name
All case which have a prefix won't be logged. In the generated js files the code for logging is missing. It took a while to find out but now i have a minimal example:
// RSLoggerBugExample.res
module Page = {
type t =
| Home
| Profile
| Welcome
}
@react.component
let make = (~page) =>
@log
switch page {
| Page.Welcome => "Hello World"->React.string
| Home => "Hello Home"->React.string
| Page.Profile => "Hello Profile"->React.string
}
// RSLoggerBugExample.bs.js
function RSLoggerBugExample(Props) {
var page = Props.page;
switch (page) {
case /* Home */0 :
Browser$ReScriptLogger.debug({
rootModule: "RSLoggerBugExample",
subModulePath: /* [] */0,
value: "make",
fullPath: "RSLoggerBugExample.make",
filePath: "absolute path to the res file which a can not disable, but that is another issue :D"
}, "Home");
return "Hello Home";
case /* Profile */1 :
return "Hello Profile";
case /* Welcome */2 :
return "Hello World";
}
}
I got this issue originally in the old reason-syntax. But I could reproduce this bug also in rescript. I'm using [email protected] & [email protected]
It's not a bug per se b/c there are a lot of things can't be displayed in the current implementation of @log attribute just b/c specific construction it's not yet handled in the matcher. I agree it should be handled though.
Implementation note: Ldot should be handled here.