dokany icon indicating copy to clipboard operation
dokany copied to clipboard

Log redirection (v2.0)

Open Karandra opened this issue 6 years ago • 9 comments

Adds log redirection options.

Checklist

  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the existing documentation
  • [x] My changes generate no new warnings
  • [ ] I have updated the change log (Add/Change/Fix)
  • [ ] I have cleaned up the commit history (use rebase and squash)

Changes proposed in this pull request:

Currently there is no way to make Dokany log its operation to user-defined target. There is an option to use stderr instead of OutputDebugStringA/W but that might not be desirable to the library user.

I've added a struct with two function to be provided by the library user that will take formatted debug string and return a BOOL value which indicated in Dokany should proceed with its own debug output. The value is TRUE by default so in case the used didn't provide any log redirection function the library will output log itself.

Karandra avatar Nov 04 '19 16:11 Karandra

Sorry, I'm idiot and couldn't find all places with DokanInit at once.

Karandra avatar Nov 04 '19 17:11 Karandra

Now it has been built successfully.

Karandra avatar Nov 04 '19 20:11 Karandra

Hi @KerberX ,

That's a good idea! Look at the function pointer, would it not be better to directly call the user function instead of our ? This way he will manage as he wants how to log it.

Like DokanDbgPrint would create the debug output and then call PDokanDbgPrint -> return Or follow the current output path.

Liryna avatar Nov 04 '19 20:11 Liryna

Yeah, that would be better indeed. I'll make the changes.

Could it be possible to implement such thing for v1.x? As far as I know there is no global Init/Shutdown routine that can initialize logging functions.

Karandra avatar Nov 04 '19 21:11 Karandra

It can be possible to implement it yes at mount time. This makes me think we should (my point of view) maybe add a param to inform from which instance this log comes from ? Or maybe not use global function pointers but function pointer attached to the instance. I agree this is more than this PR as it is already the case to log all instances at the same place 😃

Liryna avatar Nov 04 '19 21:11 Liryna

Or maybe not use global function pointers but function pointer attached to the instance.

In the same fashion as operation callbacks? I'd like that solution.

Karandra avatar Nov 04 '19 21:11 Karandra

Yes this way but maybe not directly to the dokanoperations 😄

Liryna avatar Nov 04 '19 21:11 Liryna

The new V2 has a new mandatory API named DokanInit. @Karandra if you are still interested, it would be great if you could port your work by using the API to register the struct logging functions.

Liryna avatar Jan 06 '22 21:01 Liryna

I'll see what I can do. I still need to see has been changed between that version and the current one.

Karandra avatar Jan 06 '22 21:01 Karandra