Squish Logs

Garry's Mod

Custom Logs

Log support for custom systems is easy. Squish Logs Garry's Mod Integration provides a gLua API that is easy to work with and allows you to quickly and easily integrate with your systems. This guide will provide you with a break-down of everything you need to know.

Create your first log

Creating a log is very straight forward. Logs are built in an OOP style. In the example below, a simple log is created for a category called "Chatting" that passes a simple string.

	:AddFragment('I ')
	:SetFragmentColor(Color(155, 0, 0))
	:AddFragment('love ')
	:AddFragment('to talk!')

As seen in the example, you can start a log by calling SquishLog:New(). This will return a log object, that can then be assigned "fragments". Several fragments can be assigned to build a log. Fragments make it easy to break the log up in to portions of different data.

Setting a category

At any point in the chain, you can call :SetCategory(name). This will assign the log to the provided category. name is a string, it can be a new category or an existing one. Squish Logs will attempt to find an existing catgory with the same name, or create one if not found. If no category is provided, the log will be assigned to "Other".


Coloured fragments

At any point during the chain, a colour can also be assigned with :SetFragmentColor(color). color should be a colour object. This will make the next fragment coloured. If data is provided that has internally assigned colours (e.g a Player), then that colour will be prioritized over your assigned colour.

	:SetFragmentColor(Color(60, 255, 120))
	:AddFragment('Voices ')
	:SetFragmentColor(Color(0, 0, 255))
	:AddFragment('everywhere ')
	:SetFragmentColor(Color(189, 200, 42))
	:AddFragment('send ')
	:SetFragmentColor(Color(216, 79, 20))

A set colour is only applied to the next fragment, then colour is reset.

Passing a Player

You can pass a player object to a fragment, and Squish Logs will pull any relevant information for you. This includes things like: Health, active weapon, name, etc. These logs will also be "assigned" to that player, allowing for Squish Logs to better build analytics.

	:AddFragment(' is currently talking')

If you are intending to include a player in a log, this should be the method.

Simple logs

In some cases, you might want to make a simple string log. You can do this without all the fuss of creating a Log object and chaining events by simply calling the SquishLogs.Core.SimpleLog(message, category) function. The category argument is optional.

SquishLogs.Core.SimpleLog("The universe, it sings for me!", "Communications")

Sending the log

Once your log is created and populated with a chain, you can send the log with :send(). This will have the Garry's Mod server pass the log to the websocket.

	:AddFragment('The date is ')
	:SetFragmentColor(Color(255, 0, 255))
	:AddFragment(os.date("%d/%m/%Y", os.time()))