# XO0438: log argument performs an effect

A call to `log.debug`, `log.info`, `log.warn` or `log.error` (or a Logger's) does not evaluate its arguments when the record is below the configured level. An argument that reads a file, calls the network or has another effect of its own therefore runs only sometimes, which Go's log/slog does not do. Do the work before the call (`let n = f()`) when it must always run, or keep the argument pure. See std.md 6 and decision 0558.

## Example

```xo
fn main(os: Os) uses fs.read, log {
  log.info("size", {"n": os.fs.read_file("x").len()})
}
```

## Fix

```xo
fn main(os: Os) uses fs.read, log {
  let n = os.fs.read_file("x").len()
  log.info("size", {"n": n})
}
```

Run `xo explain XO0438` for this text in a terminal, or see
[section 10.6 of the specification](../../spec/core/#106-diagnostic-codes).

