Squish Logs
Docs
Features
Price

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.

SquishLog:New()
	:SetCategory("Chatting")
	:AddFragment('I ')
	:SetFragmentColor(Color(155, 0, 0))
	:AddFragment('love ')
	:AddFragment('to talk!')
	:Send()

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".

SquishLog:New()
	:SetCategory("Chitter")
	:AddFragment('Chit-chat')
	:Send()

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.

SquishLog:New()
	:SetCategory("Talking")
	: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))
	:AddFragment('help!')
	:Send()

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.

SquishLog:New()
	:SetCategory("Verbally")
	:AddFragment(Player(1))
	:AddFragment(' is currently talking')
	:Send()

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

Metadata for text logs

Something you might find useful is assigning metadata to logs. This can be useful for giving additional context to a specific part of a log. Assigning metadata to a log is done similarly to colours, you can call the :SetFragmentMeta function, passing a function with an argument of an array, which holds sub arrays in the format of {title = "String", text = "String"}. Metadata entries must have both the title and text fields. Both metadata and colours can be stacked on a fragment, which is suggested, to make it obvious that this portion of text is relevant.

SquishLog:New()
	:SetCategory("Coms")
	:AddFragment(Player(1))
	:AddFragment(' is speaking in a ')
	:SetFragmentColor(Color(155, 0, 155))
	:SetFragmentMeta({
		{title = "Accent", text = "Cowboy"},
		{title = "Style", text = "Southern Twang"}
    })
	:AddFragment('funny voice')
	:Send()

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.

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