How to use the structlog.get_logger function in structlog

To help you get started, we’ve selected a few structlog examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vapor-ware / synse-server / tests / unit / View on Github external
def test_setup_logger_defaults():
    logger = structlog.get_logger('synse_server')

    assert logger.getEffectiveLevel() == logging.INFO
github stb-tester / stb-tester / _stbt / View on Github external
import logging
import os
import sys
from collections import OrderedDict
from contextlib import contextmanager
from textwrap import dedent

import structlog

from .config import _config_init, get_config
from .types import Region
from .utils import mkdir_p

_debug_level = None
_logger = structlog.get_logger("stbt")
_trace_logger = structlog.get_logger("stbt.trace")

def debug(msg, *args):
    """Print the given string to stderr if stbt run `--verbose` was given."""
    _logger.debug(msg, *args)

def ddebug(msg, *args):
    """Extra verbose debug for stbt developers, not end users"""
    _trace_logger.debug(msg, *args)

def warn(msg, *args):
    _logger.warning(msg, *args)
github erudit / eruditorg / eruditorg / core / subscription / management / commands / View on Github external
from import BaseCommand
from django.db import connections

from erudit.models import Journal

from core.accounts.models import LegacyAccountProfile
from core.subscription.models import (
    JournalAccessSubscription, JournalManagementSubscription, JournalAccessSubscriptionPeriod
from django.contrib.auth.models import User
from erudit.models import Organisation

from core.subscription.legacy.legacy_models import Abonneindividus

logger = structlog.get_logger(__name__)

import_date =
end_date = datetime(month=12, day=31, year=2017)

class Command(BaseCommand):

    def _get_journal_for_revueid(self, revueid):
        sql = "SELECT titrerevabr FROM revue WHERE revueid = {}".format(revueid)
        cursor = connections['legacy_subscription'].cursor()
        rows = cursor.fetchall()
        titrerevabr = rows[0][0]
        if not titrerevabr:
            raise Journal.DoesNotExist
github Flowminder / FlowKit / flowmachine / flowmachine / core / View on Github external
import redis
import structlog
from concurrent.futures import ThreadPoolExecutor
from typing import Tuple, Optional

from redis import StrictRedis

import flowmachine
from flowmachine.core import Connection
from flowmachine.core.context import bind_context, context, get_db
from flowmachine.core.errors import NotConnectedError
from flowmachine.core.logging import set_log_level
from get_secret_or_env_var import environ, getenv

logger = structlog.get_logger("flowmachine.debug", submodule=__name__)

def connections(
    log_level: Optional[str] = None,
    flowdb_port: Optional[int] = None,
    flowdb_user: Optional[str] = None,
    flowdb_password: Optional[str] = None,
    flowdb_host: Optional[str] = None,
    flowdb_connection_pool_size: Optional[int] = None,
    flowdb_connection_pool_overflow: Optional[int] = None,
    redis_host: Optional[str] = None,
    redis_port: Optional[int] = None,
    redis_password: Optional[str] = None,
    conn: Optional[Connection] = None,
github opencord / voltha / voltha / core / config / View on Github external
import structlog
from enum import Enum
from google.protobuf.json_format import MessageToDict
from google.protobuf.message import Message
from simplejson import dumps

from common.event_bus import EventBusClient
from voltha.core.config.config_proxy import CallbackType
from voltha.protos import third_party
from voltha.protos.events_pb2 import ConfigEvent, ConfigEventType

IGNORED_CALLBACKS = [CallbackType.PRE_ADD, CallbackType.GET,
                     CallbackType.POST_LISTCHANGE, CallbackType.PRE_REMOVE,

log = structlog.get_logger()

class ConfigEventBus(object):

    __slots__ = (
        '_event_bus_client',  # The event bus client used to publish events.
        '_topic'  # the topic to publish to

    def __init__(self):
        self._event_bus_client = EventBusClient()
        self._topic = 'model-change-events'

    def advertise(self, type, data, hash=None):
        if type in IGNORED_CALLBACKS:
  'Ignoring event {} with data {}'.format(type, data))
github oterrier / gracyql / app / schema / View on Github external
import uuid

import gc
import graphene
import spacy
import structlog
from graphene.types.resolver import dict_resolver
from graphql import GraphQLError
from threading import RLock

# from app.schema.ICUSentencizer import ICUSentencizer
# from app.schema.PunktSentencizer import PunktSentencizer
# from app.schema.SentenceCorrector import SentenceCorrector
#from app.pipeline.PunktSentencizer import PunktSentencizer
from app.pipeline.RuleSentencizer import RuleSentencizer
logger = structlog.get_logger("gracyql")

#from pympler import tracker, summary, muppy
#tr = tracker.SummaryTracker()

def spacy_attr_resolver(attname, default_value, root, info, **args):
    if hasattr(root, attname + '_'):
        return getattr(root, attname + '_', default_value)
        return getattr(root, attname, default_value)

def load_model(model, cfg):
    overrides = json.loads(cfg) if cfg else {}
    # overrides2 = defaultdict(dict)
    # overrides2["rule_sentencizer"]["split"] = [
    #     # Split on double line breaks
github steemit / sbds / sbds / View on Github external
# -*- coding: utf-8 -*-
import json
from urllib.parse import urlparse

import w3lib.url

import structlog

logger = structlog.get_logger(__name__)

def block_num_from_hash(block_hash: str) -> int:
    return the first 4 bytes (8 hex digits) of the block ID (the block_num)
        block_hash (str):

    return int(str(block_hash)[:8], base=16)

def block_num_from_previous(previous_block_hash: str) -> int:
github CryptoSignal / crypto-signal / app / indicators / analyzers / View on Github external
def __init__(self):
        """Initializes Utils class

        self.logger = structlog.get_logger()
github ADEQUATeDQ / portalmonitor / odpw / services / View on Github external
from odpw.core.api import DBClient
from import aggregateFormatDist
from odpw.utils.helper_functions import readDBConfFromFile
from odpw.utils.utils_snapshot import getCurrentSnapshot

import structlog
log =structlog.get_logger()

def help():
    return "perform head lookups"
def name():
    return 'UpdateStats'

def setupCLI(pa):
    #pa.add_argument("-c","--cores", type=int, help='Number of processors to use', dest='processors', default=4)
    #pa.add_argument('--pid', dest='portalid' , help="Specific portal id ")

def cli(args,dbm):
    sn = getCurrentSnapshot()
github mwaaas / ussd_airflow / ussd / View on Github external
def __init__(self, ussd_request: UssdRequest,
                 handler: str, screen_content: dict,
                 initial_screen: dict, logger=None,
        self.ussd_request = ussd_request
        self.handler = handler
        self.screen_content = screen_content
        self.raw_text = raw_text

        self.SINGLE_VAR = re.compile(r"^%s\s*(\w*)\s*%s$" % (
            '{{', '}}'))
        self.clean_regex = re.compile(r'^{{\s*(\S*)\s*}}$')
        self.logger = logger or get_logger(__name__).bind(
            screen_type=getattr(self, 'screen_type', 'custom_screen'),
        self.initial_screen = initial_screen

        self.pagination_config = self.initial_screen.get('pagination_config',

        self.pagination_more_option = self._add_end_line(
                self.pagination_config.get('more_option', "more\n")
        self.pagination_back_option = self._add_end_line(