## ASnooper
**ASnooper** is the asynchronous version of **Pysnooper**, incorporating most of its functionality for easy **debugging** in async functions as an alternative to print statements.


## Installation
```console
$ pip install ASnooper
```

## Example

Here is a base common func. While adding the `@snoop()` decorator:

```Python
import asyncio
from ASnooper import snoop


@snoop(prefix="name")
async def print_name(name: str) -> str:
    await asyncio.sleep(2)  # io

    name = f"hello {name}"  # modify var

    return name


async def main():
    await print_name("Ling")


if __name__ == '__main__':
    asyncio.run(main())
```

The output is:
```
name  11:53:19     call    5 print_name()
name           var: name = 'Ling'
name  11:53:19     line    7 print_name() await asyncio.sleep(2)    # io
name  11:53:21     call    7 print_name()
name           var: name = 'Ling'
name  11:53:21     line    9 print_name() name = f"hello {name}"    # modify var
name  11:53:21     line   11 print_name() return name
name      modified: name = 'hello Ling'
name  11:53:21   return   11 print_name()
name         watch: return = 'hello Ling'
name  Elapsed time: 2001.539ms
```

Or if you don't want to trace an entire function, you can use `async with snoop_context()`:
```Python
import asyncio
from ASnooper import snoop_context


async def print_name(name: str) -> str:
    await asyncio.sleep(2)   # io

    name = f"hello {name}"   # modify var | no trace

    async with snoop_context(prefix="name-context"):
        name += f"-context"  # modify var | trace

    return name


async def main():
    await print_name("Ling")


if __name__ == '__main__':
    asyncio.run(main())
```

The output is:
```
name-context 14:11:24     line   11 print_name() name += f"-context"   # modify var, will trace
name-context          var: name = 'hello Ling'
name-context 14:11:24     line   10 print_name() async with snoop_context(prefix="name-context"):
name-context     modified: name = 'hello Ling-context'
```

## More
Output stderr to file:
```Python
@snoop(output='debug.log')
```
See values of some expressions that aren't local variables:
```Python
@snoop(watch=('user.id',))
```
No color output:
```Python
@snoop(color=False)
```