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".
Embedding
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 !')
Mixin API
: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
Comments