本文整理匯總了Python中syslog.syslog方法的典型用法代碼示例。如果您正苦於以下問題:Python syslog.syslog方法的具體用法?Python syslog.syslog怎麽用?Python syslog.syslog使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類syslog
的用法示例。
在下文中一共展示了syslog.syslog方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def main():
if len(sys.argv) > 2:
Fatal('usage: %s [containers.yaml]' % sys.argv[0])
if len(sys.argv) == 2:
with open(sys.argv[1], 'r') as fp:
config = yaml.load(fp)
else:
config = yaml.load(sys.stdin)
syslog.openlog(PROGNAME)
LogInfo('processing container manifest')
CheckVersion(config)
all_volumes = LoadVolumes(config.get('volumes', []))
user_containers = LoadUserContainers(config.get('containers', []),
all_volumes)
CheckGroupWideConflicts(user_containers)
if user_containers:
infra_containers = LoadInfraContainers(user_containers)
RunContainers(infra_containers + user_containers)
示例2: change_email_request
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def change_email_request():
form = form_class.ChangeEmailForm()
if form.validate_on_submit():
if current_user.verify_password(form.password.data):
new_email = escape(form.email.data)
token = current_user.generate_email_change_token(new_email)
send_email(new_email,
'CVE-PORTAL -- Confirm your email address',
'/emails/change_email',
user=current_user,
token=token)
syslog.syslog(syslog.LOG_WARNING,
"User as requested an email change: Old:" + current_user.email + " New: " + form.email.data)
flash('An email with instructions to confirm your new email address has been sent to you.', 'info')
return redirect(url_for('main.index'))
else:
flash('Invalid email or password.', 'danger')
return render_template("auth/change_email.html", form=form)
示例3: change_pgp
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def change_pgp():
form = form_class.ChangePGPForm()
if form.validate_on_submit():
if current_user.verify_password(form.password.data):
ki = gpg.import_keys(form.pgp.data)
if not ki.fingerprints:
fingerp = "--- NO VALID PGP ---"
else:
fingerp = ki.fingerprints[0]
current_user.pgp = form.pgp.data
current_user.fingerprint = fingerp
models.db.session.add(current_user)
models.db.session.commit()
flash('Your PGP key has been updated.', 'info')
syslog.syslog(syslog.LOG_INFO, "User Changed his PGP: " + current_user.email)
return redirect(url_for('main.index'))
else:
flash('Invalid password.', 'danger')
return render_template("auth/change_pgp.html", form=form)
示例4: startup_message
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def startup_message():
'''Show initial status information to user and logs.
Send initial message to syslog, if --syslog specified.
Send initial message to eventlog, if --eventlog specified.
Send initial message to logfile, if --logfile specified.
'''
print()
log(APP_METADATA['full_name'] + ' Version ' + APP_METADATA['version'])
log('Copyright (C) ' + APP_METADATA['copyright'] + ' ' +
APP_METADATA['full_author'] + '. All rights reserved.')
if app_state['syslog_mode']:
syslog_send(APP_METADATA['short_name'] + ': starting...')
if app_state['eventlog_mode']:
eventlog_send(APP_METADATA['short_name'] + ': starting...')
print()
示例5: send
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def send(self, body, title='', notify_type=NotifyType.INFO, **kwargs):
"""
Perform Syslog Notification
"""
_pmap = {
NotifyType.INFO: syslog.LOG_INFO,
NotifyType.SUCCESS: syslog.LOG_NOTICE,
NotifyType.FAILURE: syslog.LOG_CRIT,
NotifyType.WARNING: syslog.LOG_WARNING,
}
# Always call throttle before any remote server i/o is made
self.throttle()
try:
syslog.syslog(_pmap[notify_type], body)
except KeyError:
# An invalid notification type was specified
self.logger.warning(
'An invalid notification type '
'({}) was specified.'.format(notify_type))
return False
return True
示例6: send_to_logs
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def send_to_logs(self):
"""Send to logs: either GAE logs (for appengine) or syslog."""
if not self._passed_rate_limit('logs'):
return self
logging.log(self.severity, self.message)
# Also send to syslog if we can.
if not self._in_test_mode():
try:
syslog_priority = self._mapped_severity(_LOG_TO_SYSLOG)
syslog.syslog(syslog_priority,
base.handle_encoding(self.message))
except (NameError, KeyError):
pass
return self
示例7: make_logger
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def make_logger(method='print', threshold=LOG_DEBUG, sid=None, output=None):
"""return a logger for the given method
known methods are 'print', 'eprint' and syslog'
"""
if method == 'print':
if output is None:
output = sys.stdout
return PrintLogger(threshold, output, sid=sid)
elif method == 'eprint':
return PrintLogger(threshold, sys.stderr, sid=sid)
elif method == 'syslog':
return SysLogger(threshold, sid)
elif method == 'file':
if not output:
raise ValueError('No logfile specified')
else:
logfile = open(output, 'a')
return PrintLogger(threshold, logfile, sid=sid)
else:
raise ValueError('Unknown logger method: %r' % method)
示例8: safe_open
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def safe_open(self):
try:
syslog.openlog(self.app, syslog.LOG_PID)
except Exception as e:
print(e)
示例9: do_write
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def do_write(self, obuf):
try:
syslog.syslog(syslog.LOG_NOTICE, obuf)
except Exception as e:
print(e)
pass
示例10: closelog
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def closelog(self):
syslog.closelog()
示例11: __init__
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def __init__(self, app, call_id = 'GLOBAL', logfile = '/var/log/sip.log'):
self.itime = time()
self.app = '/%s' % app
self.call_id = call_id
bend = os.environ.get('SIPLOG_BEND', 'stderr').lower()
tform = os.environ.get('SIPLOG_TFORM', 'abs').lower()
if tform == 'rel':
self.offstime = True
itime = os.environ.get('SIPLOG_TSTART', self.itime)
self.itime = float(itime)
self.level = eval('SIPLOG_' + os.environ.get('SIPLOG_LVL', 'INFO'))
if bend == 'stderr':
self.write = self.write_stderr
elif bend == 'none':
self.write = self.donoting
else:
self.write = self.write_logfile
self.wi_available = Condition()
self.wi = []
if bend != 'syslog':
self.logger = AsyncLogger(app, self)
self.logfile = os.environ.get('SIPLOG_LOGFILE_FILE', logfile)
self.signal_handler = LogSignal(self, SIGUSR1, self.reopen)
else:
self.logger = AsyncLoggerSyslog(app, self)
self.app = ''
示例12: LogInfo
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def LogInfo(msg):
syslog.syslog(syslog.LOG_LOCAL3 | syslog.LOG_INFO, msg)
示例13: LogError
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def LogError(msg):
syslog.syslog(syslog.LOG_LOCAL3 | syslog.LOG_ERR, msg)
示例14: Fatal
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def Fatal(*args):
"""Logs a fatal error to syslog and stderr and exits."""
err_str = 'FATAL: ' + ' '.join(map(str, args))
sys.stderr.write(err_str + '\n')
LogError(err_str)
# TODO(thockin): It would probably be cleaner to raise an exception.
sys.exit(1)
示例15: __call__
# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import syslog [as 別名]
def __call__(self, msg):
""" write a message to the log """
import syslog
syslog.syslog(self.priority, str(msg))