tauri-apps / plugins-workspace

All of the official Tauri plugins in one place!
https://tauri.app
Apache License 2.0
824 stars 224 forks source link

[log] `target` not very useful in javascript logs #1455

Open harrismcc opened 3 months ago

harrismcc commented 3 months ago

When using tauri-plugin-log, the target is not really accurate for javascript logs. It seems to always just result in the actual function in tauri-plugin-log that generates the log, not the place where I called the log function.

For example, using info("this is a test info log") in my javascript code will result in a log line like: [2024-06-11][18:22:35][INFO][log@http://localhost:1420/node_modules/.vite/deps/tauri-plugin-log-api.js:70:20] this is a test info log

Is there a way around this? Is there some configuration I'm missing on the javascript side of things (the rust locations seem to work)?

gabeidx commented 1 month ago

Technically there's a second parameter options to all log fns exposed by tauri-plugin-log: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L8-L12

export interface LogOptions {
  file?: string;
  line?: number;
  keyValues?: Record<string, string | undefined>;
}

But my experience has been that none of those parameters work 😞. They don't show up on the Rust side.

Would be a great improvement to have file and line map to the actual call site.

ktecho commented 1 month ago

Yes, totally agree with this issue. I'm currently getting this, which is not useful:

[2024-08-10][10:21:30][log@http://localhost:1420/node_modules/.vite/deps/@tauri-apps_plugin-log.js:18:20][DEBUG] Returning the ratio
realtica commented 3 weeks ago

Same here useless log for typescript: image

I prefer this until this issue will fixed: image

I'm using record.file() and record.line()