Skip to content

Commit

Permalink
docs(print): added (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason authored Sep 22, 2023
1 parent a0a59f9 commit a544562
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions pages/ox_lib/Modules/Print/Shared.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Steps, Tabs, Tab } from 'nextra-theme-docs';

# Shared

Prints to console conditionally based on convars set.
Different level prints are colored and labeled.
Resource name is always included.

## lib.print

```lua
lib.print.error(...)
lib.print.warn(...)
lib.print.info(...)
lib.print.verbose(...)
lib.print.debug(...)
```

- vararg: `any`
- What to print in console. Converts tables into a pretty-print format.

### Example

```lua
lib.print.warn("query latency high: ", latency)
```

### Levels

- Error
- Indicates a failure in the system.

- Warn
- Warns of an unexpected condition, or a state which is likely to cause an error in the future.

- Info
- Information about high-level, successful operations.

- Verbose
- More detailed information containing intermediate steps of high-level, operations

- Debug
- Used by developers to understand the system and may contain detailed trace information.
Should generally not be turned on when not debugging.

### Config
Use the following convars to set your print level. Prints less severe than the current level will not be executed.
For example, a level of info will print error, warn, and info, but not verbose nor debug. Defaults to info if not set.
Resource specific print levels override the global convar.

```bash
set ox:printlevel "info"
set ox:printlevel:ox_inventory "warn"
set ox:printlevel:<resourceName> "<level>"
```

0 comments on commit a544562

Please sign in to comment.