plugins-workspace icon indicating copy to clipboard operation
plugins-workspace copied to clipboard

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

Open harrismcc opened this issue 1 year ago • 3 comments

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)?

harrismcc avatar Jun 11 '24 18:06 harrismcc

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.

gabeins avatar Jul 17 '24 11:07 gabeins

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

ktecho avatar Aug 10 '24 10:08 ktecho

Same here useless log for typescript: image

I prefer this until this issue will fixed: image

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

realtica avatar Aug 23 '24 15:08 realtica

I believe this is fixed in #2021, can you guys confirm if it's indeed working now?

Legend-Master avatar Dec 04 '24 06:12 Legend-Master

Closing this as completed since I believe #2021 have fixed this and there're no more responses, feel free to re-open if you have any more problems though

Legend-Master avatar Apr 07 '25 02:04 Legend-Master