openmultiplayer / openmultiplayer/open.mp

Consistent logging

Open
#143 4 comments 0 reactions 1 assignee View on GitHub

@Southclaws is already working on this.

Since Aug 17, 2021.

Dominant language
C++
Stars
641
Forks
208
PR merge metrics
No merged PRs in 30d

Description

goals:

  • log natives with invalid args passed - this will help server owners surface issues they may not have known about
  • use a consistent log format, not sentences with specifiers in them but structured logs that are easy to search/filter/parse

some additional notes:

  • not JSON logs - maybe in future if there's demand but this is way too verbose I think for now
  • keep interface simple
  • common events can have composable templates:
SCRIPT_API(SendDeathMessage, bool(IPlayer* killer, IPlayer* killee, int weapon))
{
	if(killee != nullptr)
	{
		PawnManager::Get()->players->sendDeathMessageToAll(killer, *killee, weapon);
	}
	else
	{
                 // args: component name, native name, argument name
		LogTemplates::InvalidArguments("player", "SendDeathMessage", "playerid");
	}

	return true;
}

Would, potentially (if using logfmt) output:

ts=2021-01-01T12:04:11 component="player" native="SendDeathMessage" arg="playerid" msg="invalid native argument"

Which would construct a properly formatted log using a well-known structure, this would keep logs of the same types of events consistent and allow for easier searching/filtering.

In this scenario, if a server owner wants to find all the points where their script is making invalid native calls, they can filter for invalid native argument and be certain that there are no other patterns to look for - they get the native name, argument name all in one, easy to read event.

This also facilitates the ability for larger more complex servers to ingest logs into a proper log aggregator for searching and filtering. Though I'd imagine I could count on one hand how many servers would find the need for this. That being said, by facilitating this, it may help server owners investigate new tools to make their operational tasks easier.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.