> For the complete documentation index, see [llms.txt](https://docs.imerit.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.imerit.net/plugins/plugin-developer-documentation/plugin-logger.md).

# Plugin Logger

{% hint style="warning" %}
Currently, the `logger` functionality is not available for Model plugins in v3. Using it may cause issues. We will remove this notice once it is available again.
{% endhint %}

We provide plugin developers with a way to communicate to users while the plugin is being run, through log messages.

You will need to use the *PluginLogger* class, documented below:

## ango.plugin\_logger.PluginLogger

### Parameters

* **name**: *str*
* **plugin\_id**: *str*
* **org\_id**: *str*
* **run\_by**: str
* **session**: *str*
* **plugin**: *socketio.ClientNamespace*
* **level**: *logging.NOTSET*

### Functions

The only difference between these functions is the word used at the beginning of the log, between "WARNING, ERROR, DEBUG, and INFO." All four only emit log messages.

* warning(msg, \*args, \*\*kwargs)
* error(msg, \*args, \*\*kwargs)
* debug(msg, \*args, \*\*kwargs)
* info(msg, \*args, \*\*kwargs)

## Controlling plugin process log verbosity

When running a plugin script, you can set the `LOGLEVEL` environment variable to control the verbosity of the Python plugin process logs.

If `LOGLEVEL` is not set, the SDK uses `INFO`.

For example:

```bash
LOGLEVEL=WARNING python plugin.py
```

`LOGLEVEL` accepts standard Python logging levels, such as `DEBUG`, `INFO`, `WARNING`, `ERROR`, and `CRITICAL`. Setting `LOGLEVEL` to `WARNING` hides lower-priority process logs such as `INFO` and `DEBUG` output.

This setting controls the Python process logging level. It is separate from plugin-specific configuration options such as `logging_frequency`, and it should not be used as the main way to control which status messages your plugin sends to Ango Hub users through `logger.info()`, `logger.warning()`, `logger.error()`, or `logger.debug()`.

### Code Sample

```python
from imerit_ango.sdk import SDK
from imerit_ango.plugins import MarkdownPlugin, run

HOST = '<YOUR HOST>'
PLUGIN_ID = '<YOUR PLUGIN ID>'
PLUGIN_SECRET = '<YOUR PLUGIN SECRET>'

def sample_callback_function(**data):
    logger = data.get('logger')

    logger.info("Plugin session is started!")
    
    # plugin logic here #
    
    logger.info("Plugin session is ended!")
    
    if response['status'] == 'success':
        return 'All markdown files are uploaded!'
    else:
        logger.warning(response['message'])
        return response['message']


if __name__ == "__main__":
    plugin = MarkdownPlugin(id=PLUGIN_ID,
                            secret=PLUGIN_SECRET,
                            callback=sample_callback_function)

    run(plugin, host=HOST)
```

## How log messages are shown to users

Users can see the log messages you send with the *Logger* class by opening the *Plugin Sessions* dialog and expanding the row for the plugin session where they'd like to see the logs:

<figure><img src="/files/qmr93JZzUmL4HBsH8f8H" alt="" width="563"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.imerit.net/plugins/plugin-developer-documentation/plugin-logger.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
