this guide isnt finished sorry lol
What is a module?
bLogs modules make the magic happen - all logging in bLogs is done by modules. Here is an annotated example of a module:
local MODULE = GAS.Logging:MODULE() -- This creates our module object, which we interface with to define its behaviours and characteristics
MODULE.Category = "DarkRP" -- The name of the category we want this module to be a part of
MODULE.Name = "Arrests" -- The name of the module itself
MODULE.Colour = Color(255,0,0) -- The colour of the module which is seen in the menu, typically this is identical to every module that is in the same category
MODULE:Setup(function()
-- This function is called if the module is enabled, and is not called if the module is disabled.
-- The server owner/configurer states whether modules should be enabled or disabled in the menu.
-- This is where we add hooks to the module, this function is just an alias of hook.Add:
-- https://wiki.garrysmod.com/page/hook/Add
-- You can just use hook.Add, but using this function prevents clashes of hook names between modules
MODULE:Hook("playerArrested", "arrested", function(criminal, time, actor)
--[[
The following function adds a log to bLogs.
The first argument is the text of the log, it is formatted in a way so that the arguments that follow it are
injected into the log when it is being formatted. For example:
{1} arrested {2}
-> {1} will be replaced with the person who is arresting the criminal
-> {2} will be replaced with the criminal
The FormatPlayer function takes a player, SteamID, SteamID64 or AccountID as its argument and dynamically adds the
player's information (name, team, HP, armor, etc.) to the log in the specified position.
]]
MODULE:Log("{1} arrested {2}", GAS.Logging:FormatPlayer(actor), GAS.Logging:FormatPlayer(criminal))
end)
MODULE:Hook("playerUnArrested", "unarrested", function(excriminal, actor)
MODULE:Log("{1} released {2}", GAS.Logging:FormatPlayer(actor), GAS.Logging:FormatPlayer(excriminal))
end)
end)
GAS.Logging:AddModule(MODULE) -- This function adds the module object to the registry.
Creating modules for bLogs
bLogs modules are easy to create and there are a range of functions that will assist you in creating your module and formatting its logs.
1. Creating your module file
First, you need to create your module's file. This will be loaded by bLogs during server startup and this file is where you will define your categories.
Create the following file/folder structure in your addon:
addons/MY_ADDON/lua/gmodadminsuite/modules/logging/modules/MY_MODULE.lua
This file is your module file. Even if bLogs is not installed, this file will not be loaded and your addon will work as expected.
2. Defining your module's metadata
Your module's metadata is the name of it, its colour (shown in the menu) and what category it is a part of. Add the following code to your file:
local MODULE = GAS.Logging:MODULE()
MODULE.Category = "MY CATEGORY NAME"
MODULE.Name = "MY MODULE NAME"
MODULE.Colour = Color(255,0,0)
Add the name and category of your module, these can be whatever you want as long as they are strings, then, set the colour of your module using the RGB structure.
3. Adding hooks to the module
Your module now needs hooks to capture and hook into events that you want to log.