<commit_before><commit_msg>Added a json to syslog example<commit_after>import logging
import logging.handlers
import sys
import socket
import logmatic

logger = logging.getLogger()

sh = logging.handlers.SysLogHandler('/dev/log')
sh.setFormatter(logmatic.JsonFormatter(extra={"hello": "world","hostname":socket.gethostname()},prefix="appname: "))
logger.addHandler(sh)

logger.setLevel(logging.INFO)

test_logger = logging.getLogger("test")
test_logger.info({"special": "value", "run": 12})
test_logger.info("classic message", extra={"special": "value", "run": 12})

def exception_test():
    try:
        raise Exception('test')
    except Exception:
        test_logger.exception("This is a fake exception")

exception_test()
{'fraction_non_alphanumeric': 0.14718019257221457, 'fraction_numerical': 0.005502063273727648, 'mean_word_length': 6.428571428571429, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5412130', 'n_tokens_mistral': 222, 'n_tokens_neox': 220, 'n_words': 48}