Hello there! We are conducting a survey to better understand the user experience in making a first edit. If you have ever made an edit on Gamepedia, please fill out the survey. Thank you!


From WowAce Wiki
Jump to: navigation, search
Lib: DebugLog-1.0
Library providing simple debug logging.
TOC 2.4 (20400)
Category Libraries
Author Adirelle
Version 1.0
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.

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

-- Manual embedding
local 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.


Returns true if debug logs are enabled.

Library API

These methods have to be called from the library itself, e.g. :



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:

forcibly enable debug log.
forcibly disable debug log.
restores each broker state.


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)

Note on standalone version

The standalone version ships with a little code stub that makes the debugging setting persistent through sessions.