---
name: "Search::Elasticsearch::Role::Logger"
section: "3pm"
platform: "linux"
package: "libsearch-elasticsearch-perl"
version: "8.12-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Search::Elasticsearch::Role::Logger"
---

# Search::Elasticsearch::Role::Logger(3pm)

Provides common functionality to Logger implementations

## NAME

Search::Elasticsearch::Role::Logger - Provides common functionality to Logger implementations

## VERSION

version 8.12

## DESCRIPTION

This role provides common functionality to Logger implementations, to enable the logging of events and the tracing of request-response conversations with Elasticsearch nodes.

See Search::Elasticsearch::Logger::LogAny for the default implementation.

## CONFIGURATION

### "log\_to"

Parameters passed to `"log_to"` are used by Search::Elasticsearch::Role::Logger implementations to setup the "**log\_handle()**".  See Search::Elasticsearch::Logger::LogAny for details.

### "log\_as"

By default, events emitted by "**debug()**", "**info()**", "**warning()**", "**error()**" and "**critical()**" are logged to the "**log\_handle()**" under the category `"elasticsearch.event"`, which can be configured with `"log_as"`.

### "trace\_to"

Parameters passed to `"trace_to"` are used by Search::Elasticsearch::Role::Logger implementations to setup the "**trace\_handle()**". See Search::Elasticsearch::Logger::LogAny for details.

### "trace\_as"

By default, trace output emitted by "**trace\_request()**", "**trace\_response()**", "**trace\_error()**" and "**trace\_comment()**" are logged under the category `"elasticsearch.trace"`, which can be configured with `"trace_as"`.

### "deprecate\_to"

Parameters passed to `"deprecate_to"` are used by Search::Elasticsearch::Role::Logger implementations to setup the "**deprecate\_handle()**".  See Search::Elasticsearch::Logger::LogAny for details.

### "deprecate\_as"

By default, events emitted by "**deprecation()**" are logged to the "**deprecate\_handle()**" under the category `"elasticsearch.deprecation"`, which can be configured with `"deprecate_as"`.

## METHODS

### log\_handle()

Returns an object which can handle the methods: `debug()`, `debugf()`, `is_debug()`, `info()`, `infof()`, `is_info()`, `warning()`, `warningf()`, `is_warning()`, `error()`, `errorf()`, `is_error()`, `critical()`, `criticalf()` and  `is_critical()`.

### trace\_handle()

Returns an object which can handle the methods: `trace()`, `tracef()` and `is_trace()`.

### deprecate\_handle()

Returns an object which can handle the `warnf()` method.

### trace\_request()

```
    $logger->trace_request($cxn,\%request);
```

Accepts a Cxn object and request parameters and logs them if tracing is enabled.

### trace\_response()

```
    $logger->trace_response($cxn,$code,$response,$took);
```

Logs a successful HTTP response, where `$code` is the HTTP status code, `$response` is the HTTP body and `$took` is the time the request took in seconds

### trace\_error()

```
    $logger->trace_error($cxn,$error);
```

Logs a failed HTTP response, where `$error` is an Search::Elasticsearch::Error object.

### trace\_comment()

```
    $logger->trace_comment($comment);
```

Used to insert debugging comments into trace output.

### deprecation()

```
    $logger->deprecation($warning,$request)
```

Issues a deprecation warning to the deprecation logger.

## AUTHOR

Enrico Zimuel \<enrico.zimuel@elastic.co\>

## COPYRIGHT AND LICENSE

This software is Copyright (c) 2024 by Elasticsearch BV.

This is free software, licensed under:

```
  The Apache License, Version 2.0, January 2004
```
