From Riftui Wiki

Jump to: navigation, search

This page describes how to include and use the logging library of nkDebug in your addons. For a normal players there isn't that much use to nkDebug. Once messages to the catch can be caught and suppressed there'll be more use for regular players. Of course helping addon authors by providing error messages in a structured way is always a good thing. So the part of nkDebug which catches errors and displays them in a structured way makes creating screenshots of errors much easier.


Installing nkDebug

First you will need to install nkDebug. You can download it here at riftui and install it just like any other addon.

Using and opening nkDebug

As soon as you have installed the addon you'll find a small button near the minimap. If you have moved the minimap look out around where the minimap is normally positioned.

Using a left click you can open a menu. If you haven't installed any other addon from me there'll be only the entry 'nkDebug' in the menu which will pop up. By clicking on that menu entry the user interface of nkDebug will open.

If an error occurs the addon will catch it and the small button near the minimap will turn red. You can then open nkDebug to view the error on the first tab.

The addon's user interface consists of four tabs. You can switch between tabs simply by clicking on the desired tab.

Tab 'Errors'

This tab shows all errors which were caught. If an error occurs by any addon nkDebug will catch it and show it here. At the bottom of this tab you'll find two buttons which help you navigate through the error messages if more than one error was caught. Using the button 'Clear all errors' you can clear the error log.

The standard behaviour of nkDebug is to not do anything other than recording an error and turning the nkButton red. If you'd like to have the nkDebug window pop up in case of error you'll have to check the checkbox 'Open debug window on error'.

Tab 'Log'

If you use the nkLog library in one of your addons you can then view the logs created in this tab. Using two combo boxes you can select the addon and it's sub area. The grid area below will then show the log messages recorded.

There's a color coding used to indicate the log level:

   Fatal error: red
   Error: orange
   Warning: yellow
   Info: white

As soon as the tab 'Log' is opened it will auto update every second. This way you get all new log entries generated by the selected addon and sub area. Most useful when using the event in logs. You can turn of the auto update by unchecking the checkbox to the top right.

Tab 'Variables'

This tab is a bit of a left over and will see some improvements in future. At the moment you can enter a variable name in the edit box and click on 'Inspect'. If the variable is global nkDebug will lists it's contents on this page.

If the variable you'd like to view it's contents of is declared private you'll not be able to use it here.

Tab 'About'

On this tab you'll find information about the addon, myself and my various channels of communication. Of course you're most welcome to use the information about how to donate for this or any other of my addons.

Including the log in your addon

The logging mechanism is provided by a small library called 'nkLog'. In order to use the logging you'll first have to install and activate nkDebug like a normal addon. In nkDebug's installation folder you'll find a subdirectoy named 'Libs/nkLog'.Copy that directory to your addon's folder.

Next open the RiftAddon.toc file of your addon and enter these lines:

    Embed = {
      ["Libs/nkLog"] = true
    Dependencies = {
      nkDebug = {"optional", "before"},
      nkLog = {"required", "before"}

These lines will make sure that nkDebug is always loaded before your own addon and include the library into your addon. As the dependency to nkDebug is made optional this will not affect any player who's not installed nkDebug.

Using the log

In order to actually log something you'll have to create a new log instance. You can create as many log instances as you like. Each instance has it's own 'id' separating the log messages.

local myLog = nkLog.log:new('myAddonName', 'myId')
myLog:logMessage ('my message', nkLog.levelInfo)

When initiating the new log you'll have to provide the two parameters: addonName and ID.

From then on you can add a new log entry by using the logMessage function. This will require two parameters being the actual message and the log level of that entry. For your convenience there are four constants you can use:

Logging the time between two points

In addition to logging messages you can measure the time between two points in your code. This is very handy in order to measure the time your codes needs to run a certain functionality.

To do this you have to include the following command in your addon:


This command will record the exact time at that moment. By including the exact same command at a later point in your code, the library will record the exact time between the first and second command in seconds with up to 4 decimal points.

The function requires one parameter which is an id. That id can be whatever you want. Of course you'll need to provide the same id again at the second call in order to tell the library you want to record the ending point.

nkDebug will automatically create a log entry including the id and the time difference between the two calls.

Personal tools