本文整理匯總了Python中befh.util.Logger.init_log方法的典型用法代碼示例。如果您正苦於以下問題:Python Logger.init_log方法的具體用法?Python Logger.init_log怎麽用?Python Logger.init_log使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類befh.util.Logger
的用法示例。
在下文中一共展示了Logger.init_log方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Exception
# 需要導入模塊: from befh.util import Logger [as 別名]
# 或者: from befh.util.Logger import init_log [as 別名]
raise Exception("Unknown type (%s) in kdb client select statement.\n%s" % (type(select_ret), select_ret))
return ret
def delete(self, table, condition='1==1'):
"""
Delete rows from the table
:param table: Table name
:param condition: Where condition
"""
if condition == '1==1':
statement = 'delete from `%s' % (table)
else:
statement = 'delete from `%s where %s' % (table, self.parse_condition(condition))
self.conn.sync(statement)
return True
if __name__ == '__main__':
Logger.init_log()
db_client = KdbPlusClient()
db_client.connect(host='localhost', port=5000)
db_client.create('test', ['c1', 'c2', 'c3', 'c4'], ['varchar(20)', 'int', 'decimal(8, 20)', 'int'], [0], False)
db_client.insert('test', ['c1', 'c2', 'c3', 'c4'], ['abc', 1, 1.1, 5])
db_client.insert('test', ['c1', 'c2', 'c3', 'c4'], ['efg', 2, 2.2, 6])
db_client.insert('test', ['c1', 'c2', 'c3', 'c4'], ['hij', 3, 3.3, 7])
# Logger.info('test', db_client.select('test', columns=['*']))
Logger.info('test', db_client.select('test', columns=['c2', 'c3'], condition='c1 >= "abc" and c2 > 1'))
# Logger.info('test', db_client.select('test', columns=['*'], orderby='c1 desc', limit=1))
db_client.delete('test', 'c1="abc"')
示例2: main
# 需要導入模塊: from befh.util import Logger [as 別名]
# 或者: from befh.util.Logger import init_log [as 別名]
def main():
parser = argparse.ArgumentParser(description='Bitcoin exchange market data feed handler.')
parser.add_argument('-instmts', action='store', help='Instrument subscription file.', default='subscriptions.ini')
parser.add_argument('-exchtime', action='store_true', help='Use exchange timestamp.')
parser.add_argument('-kdb', action='store_true', help='Use Kdb+ as database.')
parser.add_argument('-csv', action='store_true', help='Use csv file as database.')
parser.add_argument('-sqlite', action='store_true', help='Use SQLite database.')
parser.add_argument('-mysql', action='store_true', help='Use MySQL.')
parser.add_argument('-zmq', action='store_true', help='Use zmq publisher.')
parser.add_argument('-mysqldest', action='store', dest='mysqldest',
help='MySQL destination. Formatted as <name:[email protected]:port>',
default='')
parser.add_argument('-mysqlschema', action='store', dest='mysqlschema',
help='MySQL schema.',
default='')
parser.add_argument('-kdbdest', action='store', dest='kdbdest',
help='Kdb+ destination. Formatted as <host:port>',
default='')
parser.add_argument('-zmqdest', action='store', dest='zmqdest',
help='Zmq destination. For example \"tcp://127.0.0.1:3306\"',
default='')
parser.add_argument('-sqlitepath', action='store', dest='sqlitepath',
help='SQLite database path',
default='')
parser.add_argument('-csvpath', action='store', dest='csvpath',
help='Csv file path',
default='')
parser.add_argument('-output', action='store', dest='output',
help='Verbose output file path')
args = parser.parse_args()
Logger.init_log(args.output)
db_clients = []
is_database_defined = False
if args.sqlite:
db_client = SqliteClient()
db_client.connect(path=args.sqlitepath)
db_clients.append(db_client)
is_database_defined = True
if args.mysql:
db_client = MysqlClient()
mysqldest = args.mysqldest
logon_credential = mysqldest.split('@')[0]
connection = mysqldest.split('@')[1]
db_client.connect(host=connection.split(':')[0],
port=int(connection.split(':')[1]),
user=logon_credential.split(':')[0],
pwd=logon_credential.split(':')[1],
schema=args.mysqlschema)
db_clients.append(db_client)
is_database_defined = True
if args.csv:
if args.csvpath != '':
db_client = FileClient(dir=args.csvpath)
else:
db_client = FileClient()
db_clients.append(db_client)
is_database_defined = True
if args.kdb:
db_client = KdbPlusClient()
db_client.connect(host=args.kdbdest.split(':')[0], port=int(args.kdbdest.split(':')[1]))
db_clients.append(db_client)
is_database_defined = True
if args.zmq:
db_client = ZmqClient()
db_client.connect(addr=args.zmqdest)
db_clients.append(db_client)
is_database_defined = True
if not is_database_defined:
print('Error: Please define which database is used.')
parser.print_help()
sys.exit(1)
# Subscription instruments
if args.instmts is None or len(args.instmts) == 0:
print('Error: Please define the instrument subscription list. You can refer to subscriptions.ini.')
parser.print_help()
sys.exit(1)
# Use exchange timestamp rather than local timestamp
if args.exchtime:
ExchangeGateway.is_local_timestamp = False
subscription_instmts = SubscriptionManager(args.instmts).get_subscriptions()
ExchangeGateway.init_snapshot_table(db_clients)
Logger.info('[main]', 'Subscription file = %s' % args.instmts)
log_str = 'Exchange/Instrument/InstrumentCode:\n'
for instmt in subscription_instmts:
log_str += '%s/%s/%s\n' % (instmt.exchange_name, instmt.instmt_name, instmt.instmt_code)
Logger.info('[main]', log_str)
exch_gws = []
exch_gws.append(ExchGwBtccSpot(db_clients))
exch_gws.append(ExchGwBtccFuture(db_clients))
exch_gws.append(ExchGwBitmex(db_clients))
exch_gws.append(ExchGwBitfinex(db_clients))
exch_gws.append(ExchGwOkCoin(db_clients))
#.........這裏部分代碼省略.........