Skip to content

Commit

Permalink
chore: Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Jul 28, 2023
2 parents df9e37e + 359fc48 commit 9fc884d
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
userguides/testing
userguides/scripts
userguides/publishing
userguides/logging
```

```{eval-rst}
Expand Down
2 changes: 1 addition & 1 deletion docs/userguides/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Then, add the following to your config so that Ape can find the dependency:
```yaml
dependencies:
- name: MyDependency
npm: @myorg/mydependency
npm: "@myorg/mydependency"
version: v1.3.0
```

Expand Down
49 changes: 49 additions & 0 deletions docs/userguides/logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Logging

Ape provides a logger and uses it to show messages throughout the execution of its modules.
Every CLI command comes with the logger in Ape, even custom user scripts (unless they change the behavior of `--verbosity`).

The following log levels are available with Ape:

| Log Level | Numeric Value | Purpose | Color |
| --------- | ------------- | ------------------------------ | ------ |
| DEBUG | 10 | Debug stuff | Blue |
| INFO | 20 | General information | Blue |
| SUCCESS | 21 | To mark a successful operation | Green |
| WARNING | 30 | Indicates a potential issue | Yellow |
| ERROR | 40 | An error occurred | Red |

**NOTE**: `SUCCESS` is a non-standard verbosity level custom to the framework.
It is shown during `INFO` but not shown if set to `WARNING` or above.

## CLI Logging

If you are running into issues and wish to see more information logged, you likely want to run your command with `--verbosity DEBUG` or `-v debug`:

```bash
ape --verbosity DEBUG my_cmd # long form
ape -v debug my_cmd # short form
```

This will output HTTP requests and anything else with a `DEBUG` logging verbosity in Ape.

Alternatively, you may wish to log less and show important logs, such as `ERROR` logs.
To do this, use the `ERROR` verbosity:

```bash
ape my_cmd -v ERROR
```

*NOTE*: You can put the verbosity flag anywhere in your CLI command for _most_ commands.

## Python Logging

You can also import and use the logger in your own Python scripts or commands:

```python
from ape.logging import logger, LogLevel

def main():
logger.info("You have entered `main()`.")
logger.set_level(LogLevel.WARNING)
```
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
# ** Dependencies maintained by ApeWorX **
"eip712>=0.2.1,<0.3",
"ethpm-types>=0.5.3,<0.6",
"evm-trace==0.1.0a21",
"evm-trace>=0.1.0a22",
],
entry_points={
"console_scripts": ["ape=ape._cli:cli"],
Expand Down
1 change: 1 addition & 0 deletions src/ape/pytest/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def pytest_runtest_setup(self, item):
"""
if (
self.config_wrapper.isolation is False
or isinstance(item, pytest.DoctestItem) # doctests don't have fixturenames
or "_function_isolation" in item.fixturenames # prevent double injection
):
# isolation is disabled via cmdline option
Expand Down
5 changes: 4 additions & 1 deletion src/ape_geth/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ def geth_config(self) -> GethConfig:

@property
def _clean_uri(self) -> str:
return str(URL(self.uri).with_user(None).with_password(None))
url = URL(self.uri).with_user(None).with_password(None)
# If there is a path, hide it but show that you are hiding it.
# Use string interpolation to prevent URL-character encoding.
return f"{url.with_path('')}/[hidden]" if url.path else f"{url}"

@property
def ipc_path(self) -> Path:
Expand Down

0 comments on commit 9fc884d

Please sign in to comment.