本文整理汇总了Python中syslog.setlogmask函数的典型用法代码示例。如果您正苦于以下问题:Python setlogmask函数的具体用法?Python setlogmask怎么用?Python setlogmask使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setlogmask函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, priority = message.INFO, max_length = 10000):
logger.__init__(self, priority, max_length)
if os.name == 'posix':
import syslog
self.syslog = syslog.syslog
syslog.openlog('p4dti', syslog.LOG_PID, syslog.LOG_DAEMON)
syslog.setlogmask(syslog.LOG_UPTO(priority))
开发者ID:realalien,项目名称:hs4itd4p,代码行数:7,代码来源:logger.py
示例2: __init__
def __init__(self, options, args):
"""Initialize an instance of StdEngine.
options: An object containing values for all options, as returned
by optparse
args: The command line arguments, as returned by optparse.
"""
config_dict = self.getConfiguration(options, args)
# Set a default socket time out, in case FTP or HTTP hang:
timeout = int(config_dict.get('socket_timeout', 20))
socket.setdefaulttimeout(timeout)
syslog.openlog('weewx', syslog.LOG_PID|syslog.LOG_CONS)
# Look for the debug flag. If set, ask for extra logging
weewx.debug = int(config_dict.get('debug', 0))
if weewx.debug:
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))
else:
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_INFO))
# Set up the weather station hardware:
self.setupStation(config_dict)
# Set up the services to be run:
self.setupServices(config_dict)
开发者ID:jrennie,项目名称:weewx-jrennie,代码行数:28,代码来源:wxengine.py
示例3: setUp
def setUp(self):
global config_path
global cwd
weewx.debug = 1
syslog.openlog('test_templates', syslog.LOG_CONS)
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))
# Save and set the current working directory in case some service changes it.
if not cwd:
cwd = os.getcwd()
else:
os.chdir(cwd)
try :
self.config_dict = configobj.ConfigObj(config_path, file_error=True)
except IOError:
sys.stderr.write("Unable to open configuration file %s" % config_path)
# Reraise the exception (this will eventually cause the program to exit)
raise
except configobj.ConfigObjError:
sys.stderr.write("Error while parsing configuration file %s" % config_path)
raise
# Remove the old directory:
try:
test_html_dir = os.path.join(self.config_dict['WEEWX_ROOT'], self.config_dict['StdReport']['HTML_ROOT'])
shutil.rmtree(test_html_dir)
except OSError, e:
if os.path.exists(test_html_dir):
print >> sys.stderr, "\nUnable to remove old test directory %s", test_html_dir
print >> sys.stderr, "Reason:", e
print >> sys.stderr, "Aborting"
exit(1)
开发者ID:MLAB-project,项目名称:weewx,代码行数:35,代码来源:test_templates.py
示例4: open
def open(self, verbosity=syslog.LOG_NOTICE):
log_options = syslog.LOG_PID | syslog.LOG_CONS | syslog.LOG_NDELAY
if self.options.debug:
log_options |= syslog.LOG_PERROR
syslog.openlog("conreality", logoption=log_options, facility=syslog.LOG_DAEMON)
syslog.setlogmask(syslog.LOG_UPTO(verbosity))
return self
开发者ID:conreality,项目名称:conreality,代码行数:7,代码来源:driver.py
示例5: configDatabase
def configDatabase(config_dict, binding, start_ts=start_ts, stop_ts=stop_ts, interval=interval,amplitude=1.0,
day_phase_offset=0.0, annual_phase_offset=0.0,
weather_phase_offset=0.0):
"""Configures the archive databases."""
global schema
# Check to see if it already exists and is configured correctly.
try:
with weewx.manager.open_manager_with_config(config_dict, binding) as archive:
if archive.firstGoodStamp() == start_ts and archive.lastGoodStamp() == stop_ts:
# Database already exists. We're done.
return
except weedb.DatabaseError:
pass
# Delete anything that might already be there.
try:
weewx.manager.drop_database_with_config(config_dict, binding)
except weedb.DatabaseError:
pass
# Need to build a new synthetic database. General strategy is to create the
# archive data, THEN backfill with the daily summaries. This is faster than
# creating the daily summaries on the fly.
# First, we need to modify the configuration dictionary that was passed in
# so it uses the DBManager, instead of the daily summary manager
monkey_dict = config_dict.dict()
monkey_dict['DataBindings'][binding]['manager'] = 'weewx.manager.Manager'
with weewx.manager.open_manager_with_config(monkey_dict, binding, initialize=True) as archive:
# Because this can generate voluminous log information,
# suppress all but the essentials:
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_ERR))
# Now generate and add the fake records to populate the database:
t1= time.time()
archive.addRecord(genFakeRecords(start_ts=start_ts, stop_ts=stop_ts,
interval=interval,
amplitude=amplitude,
day_phase_offset=day_phase_offset,
annual_phase_offset=annual_phase_offset,
weather_phase_offset=weather_phase_offset))
t2 = time.time()
print "\nTime to create synthetic archive database = %6.2fs" % (t2-t1,)
with weewx.manager.open_manager_with_config(config_dict, binding, initialize=True) as archive:
# Now go back to regular logging:
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))
# Backfill with daily summaries:
t1 = time.time()
nrecs, ndays = archive.backfill_day_summary()
tdiff = time.time() - t1
if nrecs:
print "\nProcessed %d records to backfill %d day summaries in %.2f seconds" % (nrecs, ndays, tdiff)
else:
print "Daily summaries up to date."
开发者ID:MLAB-project,项目名称:weewx,代码行数:60,代码来源:gen_fake_data.py
示例6: setUp
def setUp(self):
global config_path
global cwd
weewx.debug = 1
syslog.openlog('test_stats', syslog.LOG_CONS)
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))
# Save and set the current working directory in case some service changes it.
if not cwd:
cwd = os.getcwd()
else:
os.chdir(cwd)
try :
config_dict = configobj.ConfigObj(config_path, file_error=True)
except IOError:
sys.stderr.write("Unable to open configuration file %s" % self.config_path)
# Reraise the exception (this will eventually cause the program to exit)
raise
except configobj.ConfigObjError:
sys.stderr.write("Error while parsing configuration file %s" % config_path)
raise
self.archive_db_dict = config_dict['Databases'][self.archive_db]
self.stats_db_dict = config_dict['Databases'][self.stats_db]
# This will generate the test databases if necessary:
gen_fake_data.configDatabases(self.archive_db_dict, self.stats_db_dict)
开发者ID:crmorse,项目名称:weewx-waterflow,代码行数:30,代码来源:test_stats.py
示例7: chloglevel
def chloglevel(signum,frame):
if signum == signal.SIGUSR1:
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_WARNING))
syslog.syslog(syslog.LOG_WARNING,"Signal received ("+str(signum)+"). Setting logging level to WARNING.")
if signum == signal.SIGUSR2:
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_INFO))
syslog.syslog(syslog.LOG_INFO,"Signal received ("+str(signum)+"). Setting logging level to INFO.")
开发者ID:atulvarshneya,项目名称:HAHUB-software,代码行数:7,代码来源:hahubd.py
示例8: configure
def configure(self, config_dict):
parser = self.get_parser()
self.add_options(parser)
options, _ = parser.parse_args()
if options.debug is not None:
weewx.debug = options.debug
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))
prompt = False if options.noprompt else True
self.do_options(options, parser, config_dict, prompt)
开发者ID:MiddleFork,项目名称:weewx,代码行数:9,代码来源:__init__.py
示例9: gen_all
def gen_all(config_path, gen_ts = None):
syslog.openlog('reports', syslog.LOG_PID|syslog.LOG_CONS)
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))
socket.setdefaulttimeout(10)
t = weewx.reportengine.StdReportEngine(config_path, gen_ts)
t.start()
t.join()
开发者ID:jrennie,项目名称:weewx-jrennie,代码行数:10,代码来源:reports.py
示例10: setup_syslog
def setup_syslog(dest, debug=False):
if dest == 'console':
prio = dict((v, k[4:]) for k, v in vars(syslog).items() if type(v) == int and (v & 7) > 0 and k not in ('LOG_PID', 'LOG_CONS'))
syslog.syslog = lambda *m: sys.stdout.write('%s %8s: %s\n' % (str(datetime.datetime.now()), prio[m[0]], m[1])) if m[0] != syslog.LOG_DEBUG or debug else True
elif dest is not None:
syslog.openlog(ident=os.path.basename(sys.argv[0]), logoption=syslog.LOG_PID, facility=getattr(syslog, 'LOG_%s' % dest.upper()))
else:
syslog.syslog = lambda *m: True
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG if debug else syslog.LOG_INFO))
syslog.syslog(syslog.LOG_DEBUG, 'logging started')
开发者ID:mk23,项目名称:sandbox,代码行数:11,代码来源:hdfs_sync.py
示例11: set_level
def set_level(self, level):
levels = {
'error': syslog.LOG_ERR,
'warning': syslog.LOG_WARNING,
'info': syslog.LOG_INFO,
'debug': syslog.LOG_DEBUG,
}
try:
syslog.setlogmask(syslog.LOG_UPTO(levels[level]))
except KeyError:
raise LoggerError("Unknown log level while setting threshold")
开发者ID:TheFadeliskOrganization,项目名称:fadelisk,代码行数:11,代码来源:logger.py
示例12: updateFlybase
def updateFlybase():
'''
Updates genes in a MySQL database with Flybase info.
'''
syslog.openlog("FlybaseUpdater.info", 0, syslog.LOG_USER)
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_NOTICE))
syslog.syslog(syslog.LOG_NOTICE, "Starting up.")
try:
dbConn = DbConn(MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE)
if not dbConn:
syslog.syslog(syslog.LOG_CRIT, "Unable to connect to MySQL. Exiting.")
return
# Now loop every N minutes, updating flybase info.
while 1:
syslog.syslog(syslog.LOG_DEBUG, "Starting a loop.")
try:
loopStartTime = time.time()
parallelcurl = pyparallelcurl.ParallelCurl(1)
# load all genes (along with alias lists) into memory.
syslog.syslog(syslog.LOG_DEBUG, "Loading gene info.")
geneCursor = dbConn.queryDB(u'''SELECT `id`, `name`, `flybase_id`, `cg_id`, `isoform_image_path` FROM `transcription_factors` WHERE (`flybase_id` IS NOT NULL && `flybase_id` != '')''')
gene = geneCursor.fetchone()
while gene is not None:
# assemble a list of aliases for this gene.
geneInfo = {'id': int(gene[0]), 'name': str(gene[1]), 'flybase_id': str(gene[2]), 'cg_id': str(gene[3]), 'isoform_image_path': str(gene[4]), 'aliases': {}, 'isoforms': {}}
geneAliasQuery = dbConn.queryDB(u'''SELECT `id`, `name` FROM `aliases` WHERE `transcription_factor_id` = %s''', params=[str(gene[0])], newCursor=True)
alias = geneAliasQuery.fetchone()
while alias is not None:
geneInfo['aliases'][str(alias[1])] = int(alias[0])
alias = geneAliasQuery.fetchone()
# assemble a list of isoforms for this gene.
geneIsoformQuery = dbConn.queryDB(u'''SELECT `id`, `name`, `flybase_id`, `refseq_id` FROM `isoforms` WHERE `transcription_factor_id` = %s''', params=[str(gene[0])], newCursor=True)
isoform = geneIsoformQuery.fetchone()
while isoform is not None:
geneInfo['isoforms'][isoform[1].encode('utf-8')] = {'id': int(isoform[0]), 'name': isoform[1].encode('utf-8'), 'flybase_id': isoform[2].encode('utf-8'), 'refseq_id': isoform[3].encode('utf-8')}
isoform = geneIsoformQuery.fetchone()
# submit this request to parallelcurl object to be compared.
syslog.syslog(syslog.LOG_DEBUG, "Submitting request for " + gene[1])
parallelcurl.startrequest('http://flybase.org/reports/'+ str(gene[2]) +'.html', compareGeneFlybaseInfo, {'geneDBInfo': geneInfo, 'dbConn': dbConn})
gene = geneCursor.fetchone()
parallelcurl.finishallrequests()
except:
syslog.syslog(syslog.LOG_ERR, "Recoverable error:\n" + str("".join(traceback.format_exc())) + "\n")
syslog.syslog(syslog.LOG_NOTICE, "Loop finished. Sleeping for " + str(LOOP_EVERY_MINUTES) + " minutes.")
time.sleep(LOOP_EVERY_MINUTES * 60)
except:
syslog.syslog(syslog.LOG_CRIT, "Fatal error:\n" + str("".join(traceback.format_exc())) + "\n")
开发者ID:shaldengeki,项目名称:FlybaseUpdater,代码行数:50,代码来源:FlybaseUpdater.py
示例13: __init__
def __init__(self, log_facility, log_level_str):
try:
syslog.openlog(logoption=syslog.LOG_PID, facility=log_facility)
except IOError:
try:
syslog.openlog(syslog.LOG_PID, log_facility)
except IOError:
try:
syslog.openlog('swiftlm', syslog.LOG_PID,
log_facility)
except:
raise
syslog.setlogmask(syslog.LOG_UPTO(SYSLOG_LEVEL_MAP[log_level_str]))
logging.Handler.__init__(self)
开发者ID:grze,项目名称:helion-ansible,代码行数:14,代码来源:utility.py
示例14: main
def main():
# (1) ident, i.e., identity: the name of the program which will write the logging messages to syslog and will be
# prepended to every message. It defaults to sys.argv[0] with leading path components stripped if not set.
# (2) logoption: options for opening the connection or writing messages which can be an OR of multiple options,
# e.g., LOG_PID -- include PID with each message;
# LOG_CONS -- write directly to system console if there is an error while sending to system logger.
# (3) facility: specify what type of program is logging the message. For user applications, it should be the
# default value -- LOG_USER.
# For a complete list of logoption and facility values, please refer to syslog help via "man 3 syslog".
syslog.openlog(ident = 'Program-Name', logoption = syslog.LOG_PID|syslog.LOG_CONS, facility = syslog.LOG_USER)
syslog.syslog(syslog.LOG_INFO, "This is an informational message.")
# By default, syslog logs messages of all priorities. The return value of syslog.setlogmask is the old value
# of the log mask which is the default value 0xff here. The new value of the log mask is
# syslog.LOG_UPTO(syslog.LOG_ERR) = 0x0f.
oldLogMask = syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_ERR))
print "The old priority mask is 0x%x and the new priority mask is 0x%x." \
% (oldLogMask, syslog.LOG_UPTO(syslog.LOG_ERR))
# Since the priority mask is "up to" LOG_ERR, we should see the error message in /var/log/syslog but not the
# warning message.
syslog.syslog(syslog.LOG_WARNING, "This is a warning message.")
syslog.syslog(syslog.LOG_ERR, "This is an error message.")
# Reset the syslog module values (e.g., ident, logoption, facility, logmask) and call the system library closelog().
syslog.closelog()
开发者ID:renweizhukov,项目名称:Syslog,代码行数:26,代码来源:syslogExample.py
示例15: get_loglevel
def get_loglevel():
mask = syslog.setlogmask(0)
for level in (syslog.LOG_DEBUG, syslog.LOG_INFO, syslog.LOG_NOTICE,
syslog.LOG_WARNING, syslog.LOG_ERR, syslog.LOG_CRIT,
syslog.LOG_ALERT, syslog.LOG_EMERG):
if syslog.LOG_MASK(level) & mask:
return level
开发者ID:kdart,项目名称:pycopia3,代码行数:7,代码来源:logging.py
示例16: init_logging
def init_logging(target=TARGET_CONSOLE,level=DEFAULT_LOG_LEVEL):
global global_target
global global_level
if not type(level) is int:
raise RuntimeError("Unknown log level value %s" % level)
global_target=target
global_level=level
if target==TARGET_CONSOLE:
pass
elif target==TARGET_SYSLOG:
syslog.openlog("arpwatch",0,syslog.LOG_USER)
syslog.setlogmask(syslog.LOG_UPTO(global_level))
else:
raise RuntimeError("Unknown target value")
开发者ID:davidnutter,项目名称:mikrotik-arpwatch,代码行数:17,代码来源:ArpWatchLogging.py
示例17: main
def main():
syslog.openlog('ws1', syslog.LOG_PID | syslog.LOG_CONS)
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))
parser = optparse.OptionParser(usage=usage)
parser.add_option('--version', dest='version', action='store_true',
help='display driver version')
parser.add_option('--port', dest='port', metavar='PORT',
help='serial port to which the station is connected',
default=DEFAULT_PORT)
(options, args) = parser.parse_args()
if options.version:
print "ADS WS1 driver version %s" % DRIVER_VERSION
exit(0)
with Station(options.port) as s:
print s.get_readings()
开发者ID:crmorse,项目名称:weewx-waterflow,代码行数:17,代码来源:ws1.py
示例18: setUp
def setUp(self):
global config_path
global cwd
weewx.debug = 1
syslog.openlog('test_sim', syslog.LOG_CONS)
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))
# Save and set the current working directory in case some service changes it.
if not cwd:
cwd = os.getcwd()
else:
os.chdir(cwd)
try :
self.config_dict = configobj.ConfigObj(config_path, file_error=True)
except IOError:
sys.stderr.write("Unable to open configuration file %s" % config_path)
# Reraise the exception (this will eventually cause the program to exit)
raise
except configobj.ConfigObjError:
sys.stderr.write("Error while parsing configuration file %s" % config_path)
raise
(first_ts, last_ts) = _get_first_last(self.config_dict)
# Set the database to be used in the configuration dictionary
self.config_dict['StdArchive']['archive_database'] = self.archive_db
self.config_dict['StdArchive']['stats_database'] = self.stats_db
self.archive_db_dict = self.config_dict['Databases'][self.archive_db]
try:
with weewx.archive.Archive.open(self.archive_db_dict) as archive:
if archive.firstGoodStamp() == first_ts and archive.lastGoodStamp() == last_ts:
print "Simulator need not be run"
return
except weedb.OperationalError:
pass
# This will generate the simulator data:
engine = weewx.wxengine.StdEngine(self.config_dict)
try:
engine.run()
except weewx.StopNow:
pass
开发者ID:crmorse,项目名称:weewx-waterflow,代码行数:46,代码来源:test_sim.py
示例19: loadconfig
def loadconfig():
config = ConfigParser.RawConfigParser()
try:
config.read(config_path)
# syslogマスク設定
loglevel = config.get('Global', 'LogLevel')
syslog.setlogmask(syslog.LOG_UPTO(LOG[loglevel]))
slog(LOG['DEBUG'], "LogLevel: " + loglevel)
# その他設定の読み込み
global interval, cache, plugindir
interval = 24
cache = '/var/cache/ddns'
plugindir = os.path.join(os.getcwd(), 'plugin')
interval = config.getint('Global', 'UpdateInterval')
cache = os.path.normpath(config.get('Global', 'CacheDir'))
pdir = config.get('Global', 'PluginDir')
if "/" == pdir[0]:
plugindir = os.path.normpath(pdir)
else:
plugindir = os.path.normpath(os.path.join(os.getcwd(), pdir))
slog(LOG['DEBUG'], "UpdateInterval: " + str(interval))
slog(LOG['DEBUG'], "CacheDir: " + cache)
slog(LOG['DEBUG'], "PluginDir: " + plugindir)
if not os.path.exists(cache):
os.makedirs(cache)
# IPアドレスチェックサービスリストの読み込み
servers = config.items('IPAddrChecker')
global ip_checker
ip_checker = []
for key,url in servers:
ip_checker.append(url)
slog(LOG['DEBUG'], "IPChecker: " + url)
except ConfigParser.MissingSectionHeaderError:
slog(LOG['WARNING'], "MissingSectionHeader")
return False
except ConfigParser.NoSectionError:
slog(LOG['WARNING'], "NoSectionError")
return False
except ConfigParser.NoOptionError:
slog(LOG['WARNING'], "NoOptionError")
return False
except:
slog(LOG['ERR'], "Unexpected error: " + str(sys.exc_info()[:2]))
return False
return True
开发者ID:sasrai,项目名称:ddns-update,代码行数:45,代码来源:ddns_update.py
示例20: configDatabases
def configDatabases(archive_db_dict, stats_db_dict):
"""Configures the main and stats databases."""
# Check to see if it already exists and is configured correctly.
try:
with weewx.archive.Archive.open(archive_db_dict) as archive:
if archive.firstGoodStamp() == start_ts and archive.lastGoodStamp() == stop_ts:
# Database already exists. We're done.
return
except:
pass
# Delete anything that might already be there.
try:
weedb.drop(archive_db_dict)
except:
pass
# Now build a new one:
with weewx.archive.Archive.open_with_create(archive_db_dict, user.schemas.defaultArchiveSchema) as archive:
# Because this can generate voluminous log information,
# suppress all but the essentials:
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_ERR))
# Now generate and add the fake records to populate the database:
t1= time.time()
archive.addRecord(genFakeRecords())
t2 = time.time()
print "Time to create synthetic archive database = %6.2fs" % (t2-t1,)
# Now go back to regular logging:
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))
# Delete any old stats database:
try:
weedb.drop(stats_db_dict)
except weedb.NoDatabase:
pass
# Now create and configure a new one:
with weewx.stats.StatsDb.open_with_create(stats_db_dict, user.schemas.defaultStatsSchema) as stats:
t1 = time.time()
# Now backfill the stats database from the main archive database.
nrecs = stats.backfillFrom(archive)
t2 = time.time()
print "Time to backfill stats database with %d records: %6.2fs" % (nrecs, t2-t1)
开发者ID:crmorse,项目名称:weewx-waterflow,代码行数:45,代码来源:gen_fake_data.py
注:本文中的syslog.setlogmask函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论