LibDebugLog-1.0
From WowAce Wiki
| Summary | |
|---|---|
| Lib: DebugLog-1.0 | |
| Library providing simple debug logging. | |
| TOC | 2.4 (20400) |
| Category | Libraries |
| Author | Adirelle |
| Details | |
| Version | 1.0 |
| Links | |
| Betas | Ace SVN Zip |
| Changelog | FishEye |
LibDebugLog-1.0 aims at providing a simple debug API.
By default, all messages are printed to the default chat frame. But as soon as one MessageLogged callback is registered, the library becomes quiet and sends all messages through this way, see LibDebugLog-1.0/Backend-API.
Contents |
Logger API
This API is available by embedding LibDebugLog-1.0 into your addon or any table you want. It makes the target a "logger".
-- Using AceAddon-3.0
local addon = LibStub('AceAddon-3.0'):new('MyAddon', 'LibDebugLog-1.0')
function addon:SomeMethod()
self:Debug('We are in SomeMethod')
end
-- Manual embedding
local t = {}
LibStub('LibDebugLog-1.0'):Embed(t)
t:Debug('Debug !')
:Debug( msg [, ...] )
Sends a debug log message.
msg is converted to string. If more arguments are provided, they are converted to strings. If msg contains at least one '%', sends msg:format(...), else join all arguments.
-- Sends "my debug"
self:Debug('my debug')
-- Sends "one two three nil 5"
self:Debug('one', 'two', 'three', nil, 5)
-- Sends "key=5 flag=true ref=nil"
self:Debug('key=%s flag=%s ref=%s', 5, true, nil)
:ToggleDebugLog( enable )
Enable debug logging if enable is true.
:IsDebugLogEnabled()
Returns true if debug logs are enabled.
Library API
These methods have to be called from the library itself, e.g. :
LibStub('LibLogDebug-1.0'):SetGlobalToggle(false)
:Embed(broker)
Add the embeddable API into the broker and registers the broker.
:SetGlobalToggle( enable )
Forcibly set the log state of all registered brokers.
Possible values of enable are:
- true
- forcibly enable debug log.
- false
- forcibly disable debug log.
- nil
- restores each broker state.
:GetGlobalToggle()
Returns the current state of the global toggle.
:GetAce3OptionTable( logger[, order] )
Returns a table to be used as an AceConfig3 option table.
function addon:OnInitialize()
local options = {
name = 'MyAddon',
type = 'group',
handler = self,
args = {
enable = {
name = 'Enable',
type = 'toggle',
get = 'IsEnabled',
set = 'EnableAddon',
order = 100,
},
debug = LibStub('LibLogDebug-1.0'):GetAce3OptionTable(self, 110),
-- put other useful options here
}
}
LibStub("AceConfig-3.0"):RegisterOptionsTable(self.name, options)
end
Note on standalone version
The standalone version ships with a little code stub that makes the debugging setting persistent through sessions.

