View Single Post
04/23/14, 07:20 PM   #14
thelegendaryof
 
thelegendaryof's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 161
Originally Posted by Joviex View Post

I definately use d() for messages, and even if 1 person disables it, no useful infos.
You got one thing wrong thought - my Addon / Library has no public method for an Addon to surpress the Debugging Output! That choice is ultimatively up to the User in the Debug Settings and is disabled by Default. No Addon can change that - only the User.

It 's just there in case that you have an faulty Addon installed that doesn't use d() properly and spams the Chat Window with Debug-Messages and you want to disabled that output without disabling the Addon itself or having knowdlege in developing till the Addon-Developer updates his/her Addon. Thats the basic idea behind that Feature.

I really would like to add an option to disable / enable Hooks but there is no way to access the SaveData before the Addon has been completely loaded (and hooking at that point would be to late) .


Originally Posted by Joviex View Post
I almost feel there should be a way to hook the chat output with various log levels, just like any standard logger.

log.debug()
log.error()

Well that 's what I'm trying to do. It 's just called Buffers instead of Log Levels or Filters. I think I'll extend d() like explained above and add an public masked method "LibDebug.log(msg, buffer)". See this example for an explanation or better said usage example:

Lua Code:
  1. -- This will create LibDebug.Buffer.LootDrop_Messages
  2. LibDebug.AddBuffer("LootDrop_Messages")
  3.  
  4. -- This will output it's Message in the ChatWindow and store it in LibDebug.Buffer.LootDropMessages
  5. LibDebug.log("Hello this is my first Message", "LootDrop_Messages")
  6.  
  7. -- This will just add your Message to your Buffer and not output it
  8. LibDebug.AddMessage("Hello this is my second Message", "LootDrop_Messages")
  9.  
  10. -- Would be the same a LibDebug.log()
  11. d("Hello this is my second Message", "LootDrop_Messages")
  12.  
  13.  -- This would output it's Message and store it as default in LibDebug.Buffer.DEBUG
  14. d("Hello this is my third Message")
  15.  
  16. -- This would just output it's Message and NOT store it
  17. LibDebug.d("Hello this is my fourth Message")
  18.  
  19. -- This would copy the current buffer of LootDrop_Messages in MyOutput
  20. local MyOutput = LibDebug.GetBuffer("LootDrop_Messages")
  21.  
  22. -- Which would for example look like this:
  23. MyOutput = {
  24.     "Hello this is my first Message",
  25.     "Hello this is my second Message",
  26.     "Hello this is my third Message"
  27. }
  28.  
  29. -- Or you could just output the Buffer at once if you need no further logic (uses LibDebug.d internally)
  30. LibDebug.PrintMessages("LootDrop_Messages")
  31.  
  32. -- Would output it to the ChatWindow like this:
  33. -- Hello this is my first Message
  34. -- Hello this is my second Message
  35. -- Hello this is my third Message
  36.  
  37. -- This would Flush ( = Clear / Empty ) the Buffer
  38. LibDebug.FlushBuffer("LootDrop_Messages")
  39.  
  40. -- Which would result in this Output:
  41. local MyEmptyOutput = LibDebug.GetBuffer("LootDrop_Messages")
  42. MyEmptyOutput = {
  43.     -- completely empty
  44. }

Now the only thing that 's missing is a proper Filter-Logic your custom Buffer. I'm not sure if I can or would like to do such a thing or if it would limit it 's usefulness as a Library or not. I think I would probably ultimatively leave that to the Addon-Author (for example you).

Meaning I'd never surpressing any other Type of Message then those in DEBUG. So if an Addon-Author is lazy and didn't update his Addon yet and just uses d("My Debug Output") it 's output would get surpressed (but still logged and displayed in /debug!) in the Chat Window. And I repeat only if the User decided to hide them!

Simply said - all one would have to do to make it working with LibDebug is adding one additional Line and one Parameter!

Lua Code:
  1. LibDebug.AddBuffer("MyAddon_Messages")
  2. d("My Debug Output", "MyAddon_Messages")

This output wouldn't be surpressed then - even if the User decided to surpress the default "DEBUG" messages via the Debug Settings.

If he doesn't - nothing changes for him. At all, unless that he'd live with his stuff being hidden from the ChatWindow and moved to /debug - and only if the User decides so. I don't think it can be any simpler or more accepting in terms of migration. I repeat - there is no automatic suppression and no Addon implementing LibDebug can change that Setting automatically.

I'm open to suggestions if you believe I'm wrong with that kind of implementation - however please keep in mind that there 's not only the Developer but ultimatively the User. Meaning one needs some kind of choice (like surpressing bad messages) and the other one needs to easily migrate his code with as less modification as possible - or if he has no time / or doesn't care - no modification at all. After all there 's already a big number of Addons out there that are using d(). That is why I believe hooking into d() somewhat non-intrusive is the best way to get the best of both worlds together without just instantly needing to update like 500+ Addons.

Last edited by thelegendaryof : 04/23/14 at 07:56 PM.
  Reply With Quote