<s> """<STR_LIT>""" <EOL> import datetime <EOL> import json <EOL> import logging <EOL> import time <EOL> from ryu . services . protocols . bgp . rtconf . base import ConfWithId <EOL> _STATS_LOGGER = logging . getLogger ( '<STR_LIT>' ) <EOL> DEFAULT_LOG_LEVEL = logging . INFO <EOL> RESOURCE_ID = '<STR_LIT>' <EOL> RESOURCE_NAME = '<STR_LIT>' <EOL> TIMESTAMP = '<STR_LIT>' <EOL> LOG_LEVEL = '<STR_LIT>' <EOL> STATS_RESOURCE = '<STR_LIT>' <EOL> STATS_SOURCE = '<STR_LIT>' <EOL> REMOTE_ROUTES = '<STR_LIT>' <EOL> LOCAL_ROUTES = '<STR_LIT>' <EOL> UPDATE_MSG_IN = '<STR_LIT>' <EOL> UPDATE_MSG_OUT = '<STR_LIT>' <EOL> TOTAL_MSG_IN = '<STR_LIT>' <EOL> TOTAL_MSG_OUT = '<STR_LIT>' <EOL> FMS_EST_TRANS = '<STR_LIT>' <EOL> UPTIME = '<STR_LIT>' <EOL> def log ( stats_resource = None , stats_source = None , log_level = DEFAULT_LOG_LEVEL , <EOL> ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if stats_source is not None : <EOL> kwargs = stats_source ( ) <EOL> if stats_resource is None : <EOL> if RESOURCE_ID not in kwargs or RESOURCE_NAME not in kwargs : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> else : <EOL> if not ( hasattr ( stats_resource , ConfWithId . ID ) and <EOL> hasattr ( stats_resource , ConfWithId . NAME ) ) : <EOL> raise ValueError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> kwargs [ RESOURCE_ID ] = stats_resource . id <EOL> kwargs [ RESOURCE_NAME ] = stats_resource . name <EOL> if TIMESTAMP not in kwargs : <EOL> kwargs [ TIMESTAMP ] = datetime . datetime . utcfromtimestamp ( <EOL> time . time ( ) ) . strftime ( "<STR_LIT>" ) <EOL> _STATS_LOGGER . log ( log_level , <EOL> json . dumps ( kwargs ) ) <EOL> def logd ( ** kwargs ) : <EOL> log ( log_level = logging . DEBUG , ** kwargs ) <EOL> def logi ( ** kwargs ) : <EOL> log ( log_level = logging . INFO , ** kwargs ) </s>
