<commit_before>---
navtitle: log
related:
- /action/tools/log
---

# Metadata "log"

The `log` metadata disables [logging](/current/usage/logging_debugging) in an action or call a function every time the [`tools.log`](/current/action/tools/log) function is called.

* Type: `boolean|function`
* Default: `""`

When its value is `false`, it disables logging in an action and all its child actions.
When it is a function, the function is called every time the `tools.log` function is called. The [`log` object](/current/action/tools/log#log-object), [`config`](/current/action/config) and [`metadata`](/current/action/metadata) of an action are available as properties of the first argument passed to the function.

The value of the `log` metadata of a parent action is propagated to all its child actions.

## Usage

To disable logging, pass `false` to the metadata when calling an action:

```js
nikita
// Disable logging in an action and all its children
.call({
  metadata: {
    // highlight-next-line
    log: false
  }
}, function() {
  // Call a child action without logging
  this.execute('whoami')
})
```

To call a function on each `tools.log` call, pass it to the metadata:

```js
nikita
// Call an action
.call({
  metadata: {
    // Declare a function
    // highlight-range{1-6}
    log: ({log, config, metadata}) => {
      // Print properties
      console.info('log', log)
      console.info('config', config)
      console.info('metadata', metadata)
    }
  }
}, ({tools}) => {
  // Emmit a log object
  tools.log('My log message')
})
```<commit_msg>docs: review log see #336<commit_after>---
navtitle: log
related:
- /action/tools/log
---

# Metadata "log"

Dependending on its value, the `log` metadata disables [logging](/current/usage/logging_debugging) in an action or call a function every time the [`tools.log`](/current/action/tools/log) function is called.

* Type: `boolean|function`
* Default: `""`

Once defined, the `log` metadata of a parent action is propagated to all its children.

When its value is `false`, logging is disabled in the action and all its children.

When defined as a function, the function is called every time the `tools.log` function is called. The [`log`](/current/action/tools/log#log-object), [`config`](/current/action/config) and [`metadata`](/current/action/metadata) properties of the action are available in the first argument of the function.


## Usage

To disable logging, pass `false` to the metadata when calling an action:

```js
nikita
// Disable logging in an action and all its children
.call({
  // highlight-next-line
  $log: false,
}, function() {
  // Call a child action without logging
  this.execute('whoami')
})
```

To be notified when logs are emitted by `tools.log`, associate a function to the `log` metadata:

```js
nikita
// Call an action
.call({
  // Declare a function
  // highlight-range{1-6}
  $log: ({log, config, metadata}) => {
    // Print properties
    console.info('log', log)
    console.info('config', config)
    console.info('metadata', metadata)
  }
}, ({tools}) => {
  // Emmit a log object
  tools.log('My log message')
})
```
{'fraction_non_alphanumeric': 0.13450479233226836, 'fraction_numerical': 0.0022364217252396168, 'mean_word_length': 3.687125748502994, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1193808', 'n_tokens_mistral': 944, 'n_tokens_neox': 926, 'n_words': 363}