本文整理匯總了Python中logger.LOG.error方法的典型用法代碼示例。如果您正苦於以下問題:Python LOG.error方法的具體用法?Python LOG.error怎麽用?Python LOG.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類logger.LOG
的用法示例。
在下文中一共展示了LOG.error方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ebs_usage
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def ebs_usage(connect, volumes):
"""
Checks for no usage in 24 hours
"""
if type(volumes) is not list:
raise TypeError("Not a list")
unused_volumes = []
if volumes and volumes is not None:
try:
for ebs in volumes:
response = connect.cloudwatch.get_metric_statistics(Namespace='AWS/EBS',
MetricName='VolumeReadBytes',
StartTime=datetime.now() - timedelta(days=1),
EndTime=datetime.now(),
Period=86400, Statistics=['Average'],
Dimensions=[{'Name':'VolumeId','Value':ebs.id}])
if 'Datapoints' in response and not response['Datapoints']:
LOG.info("INFO: {0} is not active".format(ebs.id))
unused_volumes.append(ebs)
except Exception, err:
LOG.error("ERROR: {0}".format(err))
示例2: audit_ebs
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def audit_ebs(connect, volumes, days=None):
"""
Creates list of volumes older than X days
Defaults to 1 week
"""
if type(volumes) is not list:
raise TypeError("Not a list")
# Sets days if not specified
if not days:
date = str(datetime.now() - timedelta(days=7))
else:
date = str(datetime.now() - timedelta(days=days))
audit_tag = [{'Key':'audit','Value':str(datetime.now())}]
unused_ebs=[]
for ebs in volumes:
try:
# Gets tags for volume
for attribute in ebs.tags:
# Searches for audit tag
if attribute.get('Key') == 'audit':
# Compares audit dates
if attribute.get('Value') < date:
LOG.info("INFO: {0} ready for deletion" .format(ebs.id))
unused_ebs.append(ebs.id)
# Tags volume if missing audit tag
else:
LOG.info("INFO: Audit tag added to {0}" .format(ebs.id))
ebs.create_tags(Tags=audit_tag)
except Exception, err:
LOG.error("ERROR: {0}".format(err))
示例3: send_batch
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def send_batch(sqs_entries):
# http://boto3.readthedocs.org/en/latest/reference/services/sqs.html#SQS.Queue.sendentries
result = self.queue.send_messages(Entries=sqs_entries)
if len(result['Successful']) != len(sqs_entries):
LOG.error('Some messages failed to send to SQS: {}'.format(
result))
示例4: authenticate
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def authenticate(context, username, password):
if not have_authentication:
return True
try:
return authenticateRequest(username, password)
except Exception, e:
msg = 'Authentication failed (%s)' % e
LOG.error(msg, exc_info=True)
return xmlrpclib.Fault(123, msg)
示例5: _cleanup
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def _cleanup(self):
""" Remove old and outdated files from the temporary and
spool directory.
"""
if time.time() - self.cleanup_last > self.cleanup_after:
self._lock.acquire()
try:
self.__cleanup()
self.cleanup_last = time.time()
except Exception, e:
LOG.error(e, exc_info=True)
finally:
示例6: convertZIPEmail
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def convertZIPEmail(context, auth_token, zip_archive, converter_name='pdf-prince', sender=None, recipient=None, subject=None, body=None):
if not authorizeRequest(auth_token):
msg = 'Authorization failed'
LOG.error(msg, exc_info=True)
return xmlrpclib.Fault(123, msg)
try:
return context.convertZIPEmail(zip_archive, converter_name, sender, recipient, subject, body)
except Exception, e:
msg = 'Conversion failed (%s)' % e
LOG.error(msg, exc_info=True)
return xmlrpclib.Fault(123, msg)
示例7: convertZIP
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def convertZIP(context, auth_token, zip_archive, converter_name='pdf-prince'):
if not authorizeRequest(auth_token):
msg = 'Authorization failed'
LOG.error(msg, exc_info=True)
return xmlrpclib.Fault(123, msg)
try:
return context.convertZIP(zip_archive, converter_name)
except Exception, e:
msg = 'Conversion failed (%s)' % e
LOG.error(msg, exc_info=True)
return xmlrpclib.Fault(123, msg)
示例8: delete_vol
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def delete_vol(connect, volumes):
"""
Deletes Volumes Passed
"""
if type(volumes) is not list:
raise TypeError("Not a list")
# Currently only printing id
for ebs in volumes:
try:
LOG.info("INFO: {0} would have been deleted" .format(ebs))
except Exception, err:
LOG.error("ERROR: {0}".format(err))
示例9: handle_exc
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def handle_exc(text, obj, exc_info):
""" Handle an exception. Currently we log the exception through our own
logger. 'obj' is currently unused. We might use it later to obtain
detailed informations.
"""
# Add some addition object info iff available.
# XXX: this should be replaced with a more elegant solution
try:
text = text + ' (%s)' % obj.absolute_url(1)
except:
pass
LOG.error(text, exc_info=exc_info)
示例10: on_message
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def on_message(self, stomp_headers, json_encoded_messages):
LOG.debug('STOMP headers {}'.format(stomp_headers))
try:
messages = json.loads(json_encoded_messages)
except ValueError as e:
LOG.error('Failed to decode {} bytes as JSON: {}'.format(
len(json_encoded_messages), json_encoded_messages))
LOG.exception(e)
return
try:
self._handle_multiple_messages(messages)
except Exception as e:
LOG.exception(e)
return
示例11: convertZIPandRedirect
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def convertZIPandRedirect(context, auth_token, zip_archive, converter_name='prince-pdf', prefix=None):
""" This view appects a ZIP archive through a POST request containing all
relevant information (similar to the XMLRPC API). However the converted
output file is not returned to the caller but delivered "directly" through
the SmartPrintNG server (through an URL redirection). The 'prefix'
parameter can be used to override the basename of filename used within the
content-disposition header.
(This class is only a base class for the related http_ and xmlrpc_
view (in order to avoid redudant code).)
"""
if not authorizeRequest(auth_token):
msg = 'Authorization failed'
LOG.error(msg, exc_info=True)
return xmlrpclib.Fault(123, msg)
try:
output_archivename, output_filename = context._processZIP(zip_archive, converter_name)
output_ext = os.path.splitext(output_filename)[1]
# take ident from archive name
ident = os.path.splitext(os.path.basename(output_archivename))[0]
# move output file to spool directory
dest_filename = os.path.join(context.spool_directory, '%s%s' % (ident, output_ext))
rel_output_filename = dest_filename.replace(context.spool_directory + os.sep, '')
shutil.move(output_filename, dest_filename)
host = 'localhost'
port = 6543
prefix = prefix or ''
location = 'http://%s:%s/deliver?filename=%s&prefix=%s' % (host, port, rel_output_filename, prefix)
return location
except Exception, e:
msg = 'Conversion failed (%s)' % e
LOG.error(msg, exc_info=True)
return xmlrpclib.Fault(123, msg)
示例12: _decode_stanox
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def _decode_stanox(stanox):
try:
return locations.from_stanox(stanox)
except locations.LookupFailure:
LOG.error('Failed to look up STANOX {}.'.format(stanox))
示例13: __init__
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def __init__(self, message):
LOG.error(message)
示例14: on_error
# 需要導入模塊: from logger import LOG [as 別名]
# 或者: from logger.LOG import error [as 別名]
def on_error(self, headers, message):
LOG.error("ERROR: {} {}".format(headers, message))