Files
overextended.github.io/pages/ox_lib/Modules/Logger/Server.mdx
T
Jag 74227cc262 chore: oxmysql and ox_lib clean-up (#134)
* oxmysql and some lib interface fixes

- Various fixes throughout oxmysql
- started ox_lib audit

* chore: More clean up

- Reword some confusing descriptions
- Add some descriptions
- Type fixes
- Spelling and grammar fixes
- Swapping in `-` where `*` used to be for 
bullet point consistency

ox_lib
- Interface, ACL through GetClosestVehicle audited

* chore: Finishing up ox_lib
2023-07-03 13:13:56 +10:00

93 lines
2.8 KiB
Plaintext

import { Steps, Tabs, Tab } from 'nextra-theme-docs';
## lib.logger
```lua
lib.logger(source, event, message, ...)
```
- source: `number` or `string`
- Preferably an active player id, otherwise an identifier, or wherever else it originated from.
- event: `string`
- A name for the log event (i.e. the trigerring event or a description)
- message: `string`
- The content for the log.
- vararg: `string`
- Additional arguments are converted to tags for additional filtering and searching.
### Example
```lua
local vehicle = Ox.CreateVehicle(false, `sultanrs`, vector4(-56.479122, -1116.870362, 26.432250, 0.000030517578))
lib.logger(-1, 'CreateVehicle', json.encode(vehicle))
```
## Datadog
<Steps>
### Create your [Datadog](https://www.datadoghq.com/) account
You will receive a free 14 day trial, otherwise refer to their [pricing](https://www.datadoghq.com/pricing/) guide.
Free accounts are limited, however logs will still be retained for 14 days.
### Create an [API key](https://app.datadoghq.com/organization-settings/api-keys)
This is a UUID used to submit logs to your Datadog organisation.
### Config
Set your API key and [Datadog site](https://docs.datadoghq.com/getting_started/site/) using the following convars.
```bash
set datadog:key "yourapikey"
set datadog:site "datadoghq.com"
```
</Steps>
## Grafana Loki
Loki is a horizontally scalable, highly available, multi-tenant log aggregation system inspired by Prometheus.
It is designed to be very cost effective and easy to operate.
<Tabs items={["Cloud", "Self-hosted"]}>
<Tab>
- Has free tier with some restrictions
- Easy to manage
- Easier to setup
- Mostly managed by Grafana
<Steps>
### Create your [Grafana](https://grafana.com/) account
### Head to [My Account](https://grafana.com/auth/sign-in/?plcmt=top-nav&cta=myaccount)
### Setup Loki
Find the Loki section in your account panel, and click "Details".
Generate a password and save the API key, as well as your `user` and `url`.
</Steps>
</Tab>
<Tab>
To setup a grafana instance you'll need docker, and knowledge on containers or kubernetes.
Please find a guide to setup a grafana stack (min requirement grafana and grafana loki) and follow that.
Once done, setup authentication and use the username and password securing your endpoint.
- By default self-hosted loki instances do not provide any authentication layers and will require an external authentication layer such as NGINX basic auth or Cloudflare Access.
</Tab>
</Tabs>
<Steps>
### Config
Use the following convars to set your logging service, endpoint, and authentication details.
```bash
set ox:logger "loki"
set loki:user "<insert your user>"
set loki:password "<insert the api key or password>"
set loki:endpoint "<insert loki url without http:// or https://>"
```
</Steps>