本文整理汇总了Python中logger.logger.Logger类的典型用法代码示例。如果您正苦于以下问题:Python Logger类的具体用法?Python Logger怎么用?Python Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BinaryKnob
class BinaryKnob(object):
value = 0
pins = []
logger = None
def __init__(self, pins):
self.logger = Logger()
self.pins = pins
add_event_detection(self.pins[0], self.__handle_change, True)
add_event_detection(self.pins[1], self.__handle_change, True)
add_event_detection(self.pins[2], self.__handle_change, True)
self.__handle_change
def get_value(self):
self.__handle_change(1)
return self.value
def __handle_change(self, pin):
a = GPIO.input(self.pins[0])
b = GPIO.input(self.pins[1])
c = GPIO.input(self.pins[2])
self.value = 1
if a == True:
self.value += 1
if b == True:
self.value += 2
if c == True:
self.value += 4
self.logger.log("Selected %s" % self.value)
示例2: show_pg_warnings
def show_pg_warnings(pg_dbs=[], bkped_dbs=[], logger=None):
'''
Target:
- compare two lists with databases. This function will be used to
show which PostgreSQL databases do not have a backup in a specified
directory and which databases have a backup but are not stored in
PostgreSQL.
Parameters:
- pg_dbs: list of PostgreSQL databases.
- bkped_dbs: list of databases which have a backup.
- logger: a logger to show and log some messages.
'''
if not logger:
logger = Logger()
for dbname in pg_dbs:
if dbname not in bkped_dbs: # PostgreSQL without backup
message = Messenger.NO_BACKUP_FOR_POSTGRESQL_DB.format(
dbname=dbname)
logger.highlight('warning', message, 'purple', effect='bold')
for dbname in bkped_dbs:
# Backup of an nonexistent PostgreSQL database
if dbname not in pg_dbs:
message = Messenger.NO_POSTGRESQL_DB_FOR_BACKUP.format(
dbname=dbname)
logger.highlight('warning', message, 'purple', effect='bold')
示例3: lineReceived
def lineReceived(self, json_payloads):
Logger.trace('line received lost from network process: (%s)', json_payloads, category='client')
json_payloads.replace(self.terminator, '')
for json_payload in json_payloads.split('\n'):
json_payload = json_payload.strip('\r')
if json_payload != '':
payload = json.loads(json_payload)
self.output_queue.put(payload)
示例4: send_to_server_recursive_threaded_loop
def send_to_server_recursive_threaded_loop(connection_handler):
Logger.trace('loop from network process sender thread', category='client')
while not connection_handler.input_queue.empty():
payload = connection_handler.input_queue.get()
Logger.debug('fetch input_queue from network process sender thread', payload, category='client')
connection_handler.sendLine(json.dumps(payload))
time.sleep(0.01) # 10 ms
# get our Deferred which will be called with the largeFibonnaciNumber result
threads.deferToThread(send_to_server_recursive_threaded_loop, connection_handler)
示例5: forbid_root
def forbid_root(logger=None):
'''
Target:
- stop the execution of the program if this is being run by "root".
'''
if not logger:
logger = Logger()
try:
if getuser() == 'root': # Get system username
raise Exception()
except Exception as e:
logger.debug('Error en la función "forbid_root": {}.'.format(
str(e)))
logger.stop_exe(Messenger.ROOT_NOT_ALLOWED)
示例6: __init__
def __init__(self, connecter=None, db_backup='', new_dbname='',
logger=None):
if logger:
self.logger = logger
else:
self.logger = Logger()
if connecter:
self.connecter = connecter
else:
self.logger.stop_exe(Messenger.NO_CONNECTION_PARAMS)
if db_backup and os.path.isfile(db_backup):
self.db_backup = db_backup
else:
self.logger.stop_exe(Messenger.NO_BKP_TO_RESTORE)
if new_dbname:
self.new_dbname = new_dbname
else:
self.logger.stop_exe(Messenger.NO_DBNAME_TO_RESTORE)
message = Messenger.DB_RESTORER_VARS.format(
server=self.connecter.server, user=self.connecter.user,
port=self.connecter.port, db_backup=self.db_backup,
new_dbname=self.new_dbname)
self.logger.debug(Messenger.DB_RESTORER_VARS_INTRO)
self.logger.debug(message)
示例7: __init__
def __init__(self, pins):
self.logger = Logger()
self.pins = pins
add_event_detection(self.pins[0], self.__handle_change, True)
add_event_detection(self.pins[1], self.__handle_change, True)
add_event_detection(self.pins[2], self.__handle_change, True)
self.__handle_change
示例8: __init__
def __init__(self, pin, callback):
self.logger = Logger()
self.pin = pin
if callback is None:
add_event_detection(self.pin, self.__default_callback, True)
else:
add_event_detection(self.pin, callback, True)
self.__handle_change
示例9: create_dir
def create_dir(path, logger=None):
'''
Target:
- stop the execution of the program if this is being run by "root".
Parameters:
- path: directory to create.
- logger: a logger to show and log some messages.
'''
if not logger:
logger = Logger()
try:
if not os.path.exists(path): # If path does not exist...
os.makedirs(path) # Create it
except Exception as e:
logger.debug('Error en la función "create_dir": {}.'.format(
str(e)))
logger.stop_exe(Messenger.USER_NOT_ALLOWED_TO_CHDIR)
示例10: __init__
def __init__(self, time='', command='', logger=None):
if logger:
self.logger = logger
else:
self.logger = Logger()
self.time = time.strip()
self.command = command.strip()
示例11: __init__
def __init__(self, lighting, demo_mode=False):
self.logger = Logger()
self.demo_mode = demo_mode
self.lighting = lighting
GPIO.setup(self.coin_counter_pins, GPIO.OUT)
GPIO.setup(self.coin_input_pin, GPIO.IN)
GPIO.setup(self.coin_counter_input_pin, GPIO.IN)
self.__set_coin_count(0)
self.start_waiting_for_coin()
示例12: __init__
def __init__(self, bkp_path='', prefix='', min_n_bkps=1, exp_days=365,
max_size=5000, logger=None):
if logger:
self.logger = logger
else:
self.logger = Logger()
if bkp_path and os.path.isdir(bkp_path):
self.bkp_path = bkp_path
else:
self.logger.stop_exe(Messenger.DIR_DOES_NOT_EXIST)
if prefix is None:
self.prefix = Default.PREFIX
else:
self.prefix = prefix
if min_n_bkps is None:
self.min_n_bkps = Default.MIN_N_BKPS
elif isinstance(min_n_bkps, int):
self.min_n_bkps = min_n_bkps
elif Checker.str_is_int(min_n_bkps):
self.min_n_bkps = Casting.str_to_int(min_n_bkps)
else:
self.logger.stop_exe(Messenger.INVALID_MIN_BKPS)
if exp_days is None:
self.exp_days = Default.EXP_DAYS
elif isinstance(exp_days, int) and exp_days >= -1:
self.exp_days = exp_days
elif Checker.str_is_valid_exp_days(exp_days):
self.exp_days = Casting.str_to_int(exp_days)
else:
self.logger.stop_exe(Messenger.INVALID_OBS_DAYS)
if max_size is None:
self.max_size = Default.MAX_SIZE
elif Checker.str_is_valid_max_size(max_size):
self.max_size = max_size
else:
self.logger.stop_exe(Messenger.INVALID_MAX_TSIZE)
# Split a string with size and unit of measure into a dictionary
self.max_size = Casting.str_to_max_size(self.max_size)
# Get the equivalence in Bytes of the specified unit of measure
self.equivalence = Casting.get_equivalence(self.max_size['unit'])
# Get the specified size in Bytes
self.max_size_bytes = self.max_size['size'] * self.equivalence
message = Messenger.CL_TRIMMER_VARS.format(
bkp_path=self.bkp_path, prefix=self.prefix,
min_n_bkps=self.min_n_bkps, exp_days=self.exp_days,
max_size=self.max_size)
self.logger.debug(Messenger.CL_TRIMMER_VARS_INTRO)
self.logger.debug(message)
示例13: __init__
def __init__(self):
GPIO.setup(self.binary_output_pins, GPIO.OUT)
GPIO.setup(self.mux_enable_output_pins, GPIO.OUT)
self.logger = Logger()
self.__set_latch(self.binary_output_pins[0], 0)
self.__set_latch(self.binary_output_pins[1], 0)
self.__set_latch(self.binary_output_pins[2], 0)
self.__set_latch(self.binary_output_pins[3], 0)
self.close_boxes()
示例14: db_filter_exclude
def db_filter_exclude(dbs_list, ex_dbs=[], ex_regex='', logger=None):
'''
Target:
- filter a list of databases to remove only the specified ones,
taking into account the received parameters.
Parameters:
- dbs_list: list to filter.
- ex_dbs: list with the databases' names to exclude.
- ex_regex: regular expression which indicates the databases' names
to exclude.
- logger: a logger to show and log some messages.
Return:
- a filtered list (subset of "dbs_list"), value from the addition
of the exclude conditions "ex_dbs" y "ex_regex".
'''
if not logger:
logger = Logger()
# Copy the list to remove remove positions without conflict errors
dbs_filtered = dbs_list[:]
if '*' in ex_dbs: # If exclude all...
return [] # Return an empty list
if ex_regex:
for db in dbs_list:
dbname = db['datname']
# If database's name is in the exclusion list or matches the
# regular expression...
if dbname in ex_dbs or re.match(ex_regex, dbname):
# Remove database from the list
dbs_filtered.remove(db)
logger.debug('Base de datos excluida: {}'.format(dbname))
else:
for db in dbs_list:
dbname = db['datname']
# If database's name is in the exclusion list...
if dbname in ex_dbs:
# Remove database from the list
dbs_filtered.remove(db)
logger.debug('Base de datos excluida: {}'.format(dbname))
return dbs_filtered
示例15: on_line_received
def on_line_received(self, json_payload):
Logger.debug('line received: %s', json_payload, 'server')
payload = json.loads(json_payload)
if payload and 'type' in payload and payload['type'] == 'user_input':
user_input = UserInputDataUnit(payload['content']).get_object()
self.game.apply_user_input_to_player(self.user_id, user_input)
self.update_game()
self.send_broadcast_payload_except_self({
'type': 'user_input',
'content': payload['content'],
'user': PlayerDataUnit(self.game.get_player(self.user_id)).get_pdu()
})
self.interval_executor.execute_if_interval_elapsed(self, lambda self: self.send_broadcast_payload(
{'type': 'game_state', 'content': GameDataUnit(self.game).get_pdu()}))
else:
Logger.error('Unknown message type: (%s)', json_payload, 'server_protocol')