Metadata-Version: 2.1
Name: np-logging
Version: 0.3.1
Summary: Pre-configured file, web, and email logging for Mindscope neuropixels projects, repackaging code from AIBS mpeconfig.
Author: Ben Hardcastle
Author-email: ben.hardcastle@alleninstitute.org
Maintainer: Ben Hardcastle
Maintainer-email: ben.hardcastle@alleninstitute.org
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3
Provides-Extra: dev
Requires-Dist: black ; extra == "dev"
Requires-Dist: importlib_resources (>1.4)
Requires-Dist: isort ; extra == "dev"
Requires-Dist: mypy ; extra == "dev"
Requires-Dist: np_config
Requires-Dist: pip-tools ; extra == "dev"
Requires-Dist: poetry ; extra == "dev"
Requires-Dist: pytest ; extra == "dev"
Project-URL: Bug Tracker, https://github.com/alleninstitute/np_logging/issues
Project-URL: Repository, https://github.com/alleninstitute/np_logging
Description-Content-Type: text/markdown

**For use on internal Allen Institute network**

Quick start:
```python
import np_logging

logger = np_logging.getLogger(__name__)
```

`np_logging.setup()` with no arguments uses a default config, providing the loggers `web` and `email`, in addition to the default
`root` which includes file handlers for `logging.INFO` and `logging.DEBUG`  levels, plus
console logging. 

The built-in python `logging` module can then be used as normal.

Usage example:
```python
logging.getLogger('web').info('test: web server')
logging.getLogger('email').info('test: email logger')
logging.debug('test: root logger')
```

- user configs should be specified according to the python logging [library dict schema](https://docs.python.org/3/library/logging.config.html#logging-config-dictschema)

- the default config is fetched from the
ZooKeeper server `eng-mindscope:2181`
- configs can be added via ZooNavigator webview:
  [http://eng-mindscope:8081](http://eng-mindscope:8081)
- or more conveniently, via an extension for VSCode such as [gaoliang.visual-zookeeper](https://marketplace.visualstudio.com/items?itemName=gaoliang.visual-zookeeper)

ZooKeeper configs or config files can be used by supplying their path to `setup()`:
```python
np_logging.setup(
    '/projects/np_logging_test/defaults/logging'
)
```


Other input arguments to `np_logging.setup()`:

- `project_name` (default current working directory name) 
  
    - sets the `channel` value for the web logger
    - the web log can be viewed at [http://eng-mindscope:8080](http://eng-mindscope:8080)

- `email_address` (default `None`)
      
    - if one or more addresses are supplied, an email is sent at program exit reporting the
      elapsed time and cause of termination. If an exception was raised, the
      traceback is included.

- `log_at_exit` (default `True`)

    - If `True`, a message is logged when the program terminates, reporting total
      elapsed time.

- `email_at_exit` (default `False` or `True` if `email_address` is not `None`)

    - If `True`, an email is sent when the program terminates.
      
    - If `logging.ERROR`, the email is only sent if the program terminates via an exception.


