Skip to content

Instantly share code, notes, and snippets.

View briggleman's full-sized avatar

Ben Riggleman briggleman

View GitHub Profile
import logging
import google.cloud.logging
from google.cloud.logging.handlers.transports import BackgroundThreadTransport
from google.cloud.logging.logger import _GLOBAL_RESOURCE
DEFAULT_LOGGER_NAME = "python"
EXCLUDED_LOGGER_DEFAULTS = ("google.cloud", "google.auth", "google_auth_httplib2")
---
version: 1
disable_existing_loggers: False
formatters:
simple:
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
colored:
(): "colorlog.ColoredFormatter"
datefmt: "%Y-%m-%d %H:%M:%S"
format: "%(white)s%(asctime)s.%(msecs)03d%(reset)s - %(cyan)s[%(module)s.%(funcName)s]%(reset)s - %(log_color)s[%(levelname)s] :=>%(reset)s %(message)s"
@briggleman
briggleman / Context Decorator.py
Created October 26, 2017 17:59
An example of using the contextlib ContextDecorator class to create a class that can be used as a decorator or a context manager
import time
from contextlib import ContextDecorator
class Logger(ContextDecorator):
"""
Logger()