# Debugging

The Debugging module provides lightweight logging tools with color-coded output and timestamping, useful for both client and server contexts.

***

## Accessing the Module

```lua
local DEBUG <const> = exports.boii_utils:get("modules.debugging")
```

***

## Shared

### get\_current\_time()

Returns the current formatted time string.

#### Returns

| Type     | Description                                  |
| -------- | -------------------------------------------- |
| `string` | Current time in "YYYY-MM-DD HH:MM:SS" format |

#### Example

```lua
local time = DEBUG.get_current_time()
DEBUG.print("info", "Current time:", time)
```

***

### print(level, message, data?)

Logs a formatted message to the console with a colored prefix and optional table data. Automatically detects and prints the name of the invoking resource.

#### Parameters

| Name    | Type     | Description                                                |
| ------- | -------- | ---------------------------------------------------------- |
| level   | `string` | The log level: `debug`, `info`, `success`, `warn`, `error` |
| message | `string` | The message string to print                                |
| data?   | `table?` | Optional table to JSON encode and append to the message    |

#### Example

```lua
DEBUG.print("info", "Loading complete")
DEBUG.print("error", "Something went wrong", { code = 500, reason = "Bad request" })
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.boii.dev/old-docs/boii_utils/api/debugging.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
