Open seagullmouse opened 2 months ago
Thanks for your request! We have it on our roadmap to add WebStorm support for the plugin, and part of that work will involve adding the log framework detection required to show log insights for TypeScript. Which log framework do you use?
Using winston. Thanks
The latest plugin release (v1.5.4) includes log detection for Winston, please give it a try!
Just testing this now and I can't see the logs in IntelliJ, but I can see them in the Datadog webapp itself. FYI my code is Typescript.
I have the Datadog inlay hints turned on for both TypeScript and JavaScript.
Let me know what else I can give you to debug.
@seagullmouse Could the code you are working on use the global winston methods rather than those on a logger object?
E.g.
import {warn} from "winston";
function hello() {
warn("foo")
}
Hi, we are in a large monorepo that has a shared logging package, that adds a bunch of stuff to the logger (e.g. log levels, container names etc, tags). Maybe this won't work for us after all then?
Indeed that may not work depending on the changes, the detection used the winston.Logger
type, and the next release will instead detect if the function is a LeveledLogMethod
rather than use the qualifier type (winston.Logger
), maybe that will help your project's customizations.
@seagullmouse Hello, we released 1.5.5 last week, did it help in your case ?
@bric3 unfortunately not.
Some pseudocode might help
// central-logger package
function createLogger(name: string){
// set up formats
// set log levels based on environment variables
// set transports
// Add to winston container or get the existing logger if it's already there
logger.debug("Creating logger, I can see the usage hint here!")
}
export const logger = createLogger("name");
// In a microservice
import { logger } from "central-logger";
logger.info("this log shows in Datadog UI but the usage hint doesn't show in IntelliJ")
@seagullmouse In the log facade, does the log methods themselves have a different type than winston.LeveledLogMethod
?
I could probably add support for this kind of declarations, but the method type has to come from a union/intersection with either winston.LeveledLogMethod
or winston.LogMethod
.
declare namespace custom {
type CustomLeveledLogMethod = {
foo: string;
} & LeveledLogMethod
type CustomLogger = {
info: CustomLeveledLogMethod;
}
let createLogger: (name: string) => CustomLogger;
}
export = custom;
Just looking at our code, we abstract away from Winston types to a simple Logger type
Again, I appreciate there may be a mismatch between your work and our code here. It's Winston under the hood but you can't see that in the calling code.
Again, I appreciate there may be a mismatch between your work and our code here. It's Winston under the hood but you can't see that in the calling code.
Indeed, and I'm not sure we should try to support Log*
types that are not "derived" from winston types.
Can't see log insights in my Node.js (Typescript) code