本文整理汇总了Python中settings.get_logger函数的典型用法代码示例。如果您正苦于以下问题:Python get_logger函数的具体用法?Python get_logger怎么用?Python get_logger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_logger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, session=None, server=None):
self.logger = settings.get_logger(settings.LOG, self.__class__.__name__)
self.session = session
self.server = server
self.connect()
self.db = self._conn[self.Meta.db]
self.admin_db = self._conn[settings.ADMIN_DB]
self.collection = self._conn[self.Meta.db][self.Meta.collection]
示例2: __init__
def __init__(self, port):
self.logger = settings.get_logger(settings.LOG, self.__class__.__name__)
#sockets = tornado.netutil.bind_sockets(port)
#tornado.process.fork_processes(0)
server = tornado.httpserver.HTTPServer(TORNADO_APP)
server.bind(port)
server.start()
settings.startup()
self.logger.debug("Server Started: %s" % port)
tornado.ioloop.IOLoop.instance().start()
示例3: __init__
def __init__(self, view=View, *args, **kwargs):
super(Model, self).__init__(*args, **kwargs)
self.logger = settings.get_logger(settings.LOG, self.__class__.__name__)
self.admin_db = self.__conn__[self.__admindb__]
self.__logs__ = []
self.__view__ = view(context=self) if not self.__currentview__ else self.__currentview__(context=self)
try:
self.init(*args, **kwargs)
except Exception as e:
self.logger.exception(e)
pass
示例4: get_file_config
def get_file_config(filepath):
logger = settings.get_logger('blippd')
try:
with open(filepath) as f:
conf = f.read()
return json.loads(conf)
except IOError as e:
logger.exc('get_file_config', e)
logger.error('get_file_config',
msg="Could not open config file... exiting")
exit(1)
except ValueError as e:
logger.exc('get_file_config', e)
logger.error('get_file_config',
msg="Config file is not valid json... exiting")
exit(1)
示例5: main
def main():
"""Run periscope"""
ssl_opts = None
logger = settings.get_logger()
logger.info('periscope.start')
loop = tornado.ioloop.IOLoop.instance()
# parse command line options
tornado.options.parse_command_line()
app = PeriscopeApplication()
if settings.ENABLE_SSL:
ssl_opts = settings.SSL_OPTIONS
http_server = tornado.httpserver.HTTPServer(app, ssl_options=ssl_opts)
http_server.listen(options.port, address=options.address)
loop.start()
logger.info('periscope.end')
示例6: main
def main(options=None):
options = get_options() if not options else options
logger = settings.get_logger('blippd', options['--log'], options['--log-level'])
conf = deepcopy(settings.STANDALONE_DEFAULTS)
cconf = {
"id": options.get("--service-id", None),
"name": "blipp",
"properties": {
"configurations": {
"unis_url": options.get("--unis-url", None),
}
}
}
delete_nones(cconf)
merge_dicts(conf, cconf)
if options['--config-file']:
fconf = get_file_config(options['--config-file'])
merge_dicts(conf, fconf)
bconf = BlippConfigure(initial_config=conf,
node_id=options['--node-id'],
pre_existing_measurements=options['--existing'],
urn=options['--urn'])
bconf.initialize()
config = bconf.config
logger.info('main', config=pprint.pformat(config))
logger.warn('NODE: ' + HOSTNAME, config=pprint.pformat(config))
if options['--daemonize']:
with daemon.DaemonContext():
arbiter.main(bconf)
else:
arbiter.main(bconf)
示例7: ord
import json
import requests
import sys
import uuid
import os
from stat import ST_MTIME
from multiprocessing import Process, Pipe
from ms_client import MSInstance
from unis_client import UNISInstance
from collector import Collector
from sched_obj import SchedObj, FakeDict
import settings
logger = settings.get_logger("sched")
SETTINGS_FILE = os.path.dirname(__file__) + "/settings.py"
if settings.DEBUG:
for item in dir(settings):
if ord(item[0]) >= 65 and ord(item[0]) <= 90:
logger.debug("settings", item=item, value=str(settings.__getattribute__(item))) # @UndefinedVariable
# loop every check interval:
# check settings file and reload
# check probe_settings files and add to probes_reload if changed
# loop probes:
# does it have a process?
# no: create and start it
# yes: is it not alive?
# join it check exit code
示例8: __init__
import settings
import shlex
import dateutil.parser
import calendar
import re
logger = settings.get_logger("netlogger_probe")
class Probe:
def __init__(self, service, measurement):
self.config = measurement["configuration"]
self.logfile = None
try:
self.logfile = open(self.config["logfile"])
except KeyError:
logger.warn("__init__", msg="Config does not specify logfile!")
except IOError:
logger.warn("__init__", msg="Could not open logfile: %s" % self.config["logfile"])
self.app_name = self.config.get("appname", "")
self.et_string = "ps:tools:blipp:netlogger:"
if self.app_name:
self.et_string += self.app_name + ":"
def get_data(self):
if self.logfile:
ret = []
self.logfile.seek(self.logfile.tell())
for line in self.logfile:
if "VAL" not in line:
示例9: __init__
import settings
import time
import socket
from collector import Collector
from utils import blipp_import
import pprint
HOSTNAME = socket.gethostname()
logger = settings.get_logger('probe_runner')
rtt_list = []
collect_rtt_list = []
class ProbeRunner:
'''
Class to handle a single probe. Creates the scheduler, collector,
and probe module associated with this probe. The run method should
be called as a subprocess (by arbiter) and passed a
connection object so that it can receive a "stop" if necessary.
'''
def __init__(self, service, measurement):
self.measurement = measurement
self.config = measurement['configuration']
self.service = service.config
self.probe_defaults = service.probe_defaults
self.setup()
def run(self, conn, ip):
if conn.poll() and conn.recv() == "stop":
self._cleanup()
exit()
示例10: __init__
from ms_client import MSInstance
from data_logger import DataLogger
from unis_client import UNISInstance
import settings
logger = settings.get_logger("collector")
class Collector:
"""Collects reported measurements and aggregates them for
sending to MS at appropriate intervals.
Also does a bunch of other stuff which should probably be handled by separate classes.
Creates all the metadata objects, and the measurement object in UNIS for all data inserted.
Depends directly on the MS and UNIS... output could be far more modular.
"""
def __init__(self, service, measurement):
self.config = measurement["configuration"]
self.service = service
self.measurement = measurement
self.collections_created = False
self.ms = MSInstance(service, measurement)
self.dl = DataLogger(service, measurement)
self.mids = {} # {subject1: {metric1:mid, metric2:mid}, subj2: {...}}
# {mid: [{"ts": ts, "value": val}, {"ts": ts, "value": val}]}
self.mid_to_data = {}
self.mid_to_et = {}
self.unis = UNISInstance(service)
self.num_collected = 0
示例11: ServiceConfigure
from unis_client import UNISInstance
import settings
import pprint
from utils import merge_dicts
logger = settings.get_logger('conf')
class ServiceConfigure(object):
'''
ServiceConfigure is meant to be a generic class for any service
which registers itself to, and gets configuration from UNIS. It
was originally developed for BLiPP, but BLiPP specific features
should be in the BlippConfigure class which extends
ServiceConfigure.
'''
def __init__(self, initial_config={}, node_id=None, urn=None):
if not node_id:
node_id = settings.UNIS_ID
self.node_id = node_id
self.urn = urn
self.config = initial_config
self.unis = UNISInstance(self.config)
self.service_setup = False
def initialize(self):
self._setup_node(self.node_id)
self._setup_service()
def refresh(self):
r = self.unis.get("/services/" + self.config["id"])
示例12: Technologies
# license. See the COPYING file for details.
#
# This software was created at the Indiana University Center for Research in
# Extreme Scale Technologies (CREST).
# =============================================================================
'''
Server for blipp configuration and control via cmd line interface.
'''
import zmq
import settings
import json
import time
from config_server_api import RELOAD, GET_CONFIG, POLL_CONFIG
logger = settings.get_logger('config_server')
class ConfigServer:
def __init__(self, conf_obj):
self.context = zmq.Context()
self.conf_obj = conf_obj
self.changed = True
self.socket = self.context.socket(zmq.REP)
self.socket.bind("ipc:///tmp/blipp_socket_zcWcfO0ydo")
def listen(self, timeout):
cur_time = time.time()
finish_time = cur_time + timeout
while cur_time < finish_time:
logger.info("listen", msg="polling for %d"%(finish_time-cur_time))
if self.socket.poll((finish_time - cur_time)*1000):
示例13: __init__
from blipp_conf import BlippConfigure
import settings
import arbiter
from utils import merge_dicts, delete_nones
FIELD_LEN = 10
VERSION = "0.0.1"
REQUEST_TYPE = "1"
MESSAGE_LEN = 512
MAX_HOST_LEN = 256
SUCCESS = 1
FAILURE = 2
HOSTNAME = socket.gethostname()
logger = settings.get_logger('ablippd')
iplist = []
class LboneServer:
def __init__(self, host, port):
self.host = host
self.port = int(port)
def GetDepot(self, numDepots, hard, soft, duration, location, timeout):
str_final_req = []
str_final_req.append(self.PadField(VERSION))
str_final_req.append(self.PadField(REQUEST_TYPE))
str_final_req.append(self.PadField(str(numDepots)))
str_final_req.append(self.PadField(str(hard)))
示例14: check_ffmpeg
#!/usr/bin/env python
'''
Creates image with size settings.THUMBNAIL_WIDTH, settings.THUMBNAIL_HEIGHT for
each video file.
'''
import os
import shutil
import subprocess
import sys
_CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(_CURRENT_DIR, '..'))
import settings # pylint: disable=import-error, wrong-import-position
log = settings.get_logger('create_video_thumbnails') # pylint: disable=invalid-name
def check_ffmpeg():
'''
Checks that ffmpeg is available.
:return: True if ffmpeg has been found, False otherwise.
'''
try:
subprocess.check_call(['ffmpeg', '-version'])
except subprocess.CalledProcessError:
return False
return True
def get_video_files_list(path):
示例15: Technologies
#
# This software may be modified and distributed under the terms of the BSD
# license. See the COPYING file for details.
#
# This software was created at the Indiana University Center for Research in
# Extreme Scale Technologies (CREST).
# =============================================================================
import time
import settings
from probe_runner import ProbeRunner
from multiprocessing import Process, Pipe
from copy import copy
from config_server import ConfigServer
import pprint
logger = settings.get_logger('arbiter')
PROBE_GRACE_PERIOD = 10
class Arbiter():
'''
The arbiter handles all of the Probes. It reloads the config every
time the unis poll interval comes around. If new probes have been
defined or if old probes removed, it starts and stops existing
probes.
Each probe is run by the ProbeRunner class in a separate
subprocess. The arbiter has a dictionary which contains the
process object for each probe, and the connection object to that
process. The arbiter can send a "stop" string through the
connection to give a probe the chance to shut down gracefully. If