<!-- Page: https://rustic-game-engine.pages.dev/docs/api/logging/warn -->

# warn()

[Logging](https://rustic-game-engine.pages.dev/markdown/api/logging.md)

## Compatibility

**Supported languages:** Lua 5.4, Luau, JavaScript and HTML/inline JavaScript; other languages use rustic.print/rustic.warn.

Use a compatible native engine build and the language tools required by your binding. This does not establish browser/mobile export or release qualification for every OS.

The signature below is the shared reference notation; language examples show the actual binding syntax. Question marks mark optional arguments and explicit defaults are shown where recorded. Do not copy reference notation as a typed declaration.

See [Feature status and compatibility](https://rustic-game-engine.pages.dev/markdown/reference/compatibility.md) for API 1.0/1.1 and per-method restrictions. Engine release tags and Docs v0.1 are independent versions.

## Signature

`warn(...)`

## Setup and usage

Log lifecycle transitions and recoverable errors. Avoid per-frame logging outside short debugging sessions because bounded queues can drop excessive output.

## Parameters

| Variable | Type | Required | Description |
| --- | --- | --- | --- |
| `level` | string | Yes | debug, info, warn, or error. |
| `message` | string | Yes | Human-readable diagnostic text. |

## Return and timing

No value. The message is queued for the bounded console sink.

## Execution behavior

Core write timing differs between immediate Lua host calls, deferred JavaScript/Web commands and external SDK query flushes. Scheduled actions advance with the scene clock; synchronous queries evaluate at the call. Follow [execution rules](https://rustic-game-engine.pages.dev/markdown/guides/scripting.md#when-mutations-take-effect) and the return/timing notes for this category.

## Language examples

Use these snippets inside Start/on_start after generating the Programming Workspace and attaching the script. Python imports rustic, Game and instance from rustic; C++ includes rustic.hpp; C includes rustic.h; C# uses using static Rustic; Java runs inside a Rustic subclass; PHP declares global $rustic, $Game, $instance in its callback. HTML uses an inline script in a ui/ asset. See [Lifecycle callbacks](https://rustic-game-engine.pages.dev/markdown/callbacks.md) for complete registration examples. Public-property examples require a declared integer health property. Scene examples require the named objects to exist before Play.

### Lua 5.4

```lua
rustic.log('info', 'player spawned')
print("spawned")
warn("low health")
```

### JavaScript

```javascript
rustic.log('info', 'player spawned');
print("spawned");
warn("low health");
```

### Python

```python
rustic.log('info', 'player spawned')
rustic.print("spawned")
rustic.warn("low health")
```

### C++

```cpp
rustic.log("info", "player spawned");
rustic.print("spawned");
rustic.warn("low health");
```

### C#

```csharp
rustic.log("info", "player spawned");
rustic.print("spawned");
rustic.warn("low health");
```

### Luau

```lua
rustic.log('info', 'player spawned')
print("spawned")
warn("low health")
```

### C

```c
rustic.log("info", "player spawned");
rustic.print("spawned");
rustic.warn("low health");
```

### Java

```java
rustic.log("info", "player spawned");
rustic.print("spawned");
rustic.warn("low health");
```

### PHP

```php
$rustic->log('info', 'player spawned');
$rustic->print("spawned");
$rustic->warn("low health");
```

### HTML / inline JS

```javascript
rustic.log('info', 'player spawned');
print("spawned");
warn("low health");
```

## Shared Logging constraints

- In Lua and JavaScript, print(...) writes an info entry and warn(...) writes a warning entry to the Rustic Console. Lua separates multiple arguments with tabs; JavaScript separates them with spaces. Use rustic.log for an explicit level. External programs must not print diagnostics to stdout; stdout is reserved for protocol responses.
- Every gameplay language calls the engine-owned API. Rustic supplies SDKs and dispatches callbacks; scripts do not parse requests or serialize responses. See the language guide for complete setup and callback registration.

## Errors and debugging

Read the constraints above and the Console diagnostic. Invalid types, non-finite values, stale targets or unavailable native services can fail validation. A failed callback disables the behavior; a failed source reload keeps the last good instance. Exact error messages depend on the language adapter. See [Troubleshooting](https://rustic-game-engine.pages.dev/markdown/troubleshooting.md).

## Related APIs

- [rustic.log()](https://rustic-game-engine.pages.dev/markdown/api/logging/log.md)
- [print()](https://rustic-game-engine.pages.dev/markdown/api/logging/print.md)

[All logging APIs](https://rustic-game-engine.pages.dev/markdown/api/logging.md)
