Metadata-Version: 2.4
Name: jamsuite-logger
Version: 0.9.0
Summary: JSON structured logger
Project-URL: Homepage, https://github.com/JamSuite/jamsuite-logger
Project-URL: Documentation, https://github.com/JamSuite/jamsuite-logger#readme
Project-URL: Repository, https://github.com/JamSuite/jamsuite-logger
Project-URL: Issues, https://github.com/JamSuite/jamsuite-logger/issues
Author-email: JamSuite Developers <opensource@jamsuite.com>
Maintainer-email: JamSuite Developers <opensource@jamsuite.com>
License: Apache-2.0 License
License-File: LICENSE
Keywords: jamsuite,json-logger,logger,logging,structured-logger
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
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.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: System :: Logging
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# JamSuite Logger

```
                                                 
                                                 
   ██  ▄▄▄  ▄▄   ▄▄ ▄█████ ▄▄ ▄▄ ▄▄ ▄▄▄▄▄▄ ▄▄▄▄▄ 
   ██ ██▀██ ██▀▄▀██ ▀▀▀▄▄▄ ██ ██ ██   ██   ██▄▄  
████▀ ██▀██ ██   ██ █████▀ ▀███▀ ██   ██   ██▄▄▄ 
                          .                  
                          |    _  _  _  _ ._.
                          |___(_)(_](_](/,[  
                                 ._|._|                              
```
<!-- 

https://patorjk.com/software/taag/#p=display&f=ANSI%20Compact&t=JamSuite&x=none 
https://patorjk.com/software/taag/#p=display&f=Contessa&t=Logger&x=none

-->

Structured JSON Logging for Python



# Logging convention

JamSuite Logger provides a JSONFormatter that converts the log message to JSON. If the message is a simple string, it gets set as the `message` attribute inside the log message. 

## Standard attributes

JamSuite's JSONFormatter will add attributes that start with the `log_` prefix to each message including the timestamp, source file, and level.

## String messages logged as JSON

```python
>>> log.info("just log a string")
{
  "log_time": "2025-12-14 10:13:33,989",
  "log_source": "__main__",
  "log_level": "INFO",
  "message": "just log a string"
}
```

## Dictionaries logged as JSON

Most commonly, you'll use dictionaries to represent the log message.

```python
>>> log.info({"message":"Hey Ma, look at me!","user":"Your Kid!"})
{
  "log_time": "2025-12-14 10:11:31,177",
  "log_source": "__main__",
  "log_level": "INFO",
  "message": "Hey Ma, look at me!",
  "user": "Your Kid!"
}
```

## Exception Logging

If you put an exception inside the message its message will get added to the JSON log message.

```python
>>> e = Exception("woah there!")
>>> log.info(e)
{
  "log_time": "2025-12-14 10:15:38,324",
  "log_source": "__main__",
  "log_level": "INFO",
  "message": "woah there!"
}
```

To capture exception information, set exc_info kwarg as you would in Python logging.

```python
>>> try:
...     raise(Exception("woah there!"))
... except Exception as e:
...     log.error("Caught exception in try block", exc_info=e)
... 
{
  "log_time": "2025-12-14 10:18:06,249",
  "log_source": "__main__",
  "log_level": "ERROR",
  "message": "Caught exception in try block",
  "log_exception": "Exception(woah there!)",
  "log_traceback": [
    "<stdin> line 2 in <module>: "
  ]
}
```

