Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 903ac7f

Browse files
authored
Merge pull request #500 from cpacia/master
Add cmd line flag to disable audit log
2 parents 09c108c + 87c7189 commit 903ac7f

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

market/audit.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ class Audit(object):
88
A class for handling audit information
99
"""
1010

11-
def __init__(self, db):
11+
def __init__(self, db, enabled=True):
1212
self.db = db
13+
self.enabled = enabled
1314

1415
self.log = Logger(system=self)
1516

@@ -23,6 +24,8 @@ def __init__(self, db):
2324
}
2425

2526
def record(self, guid, action_id, contract_hash=None):
27+
if self.enabled is not True:
28+
return
2629
self.log.info("Recording Audit Event [%s]" % action_id)
2730

2831
if action_id in self.action_ids:

market/contracts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,8 +949,8 @@ def payment_received(self):
949949
if self.db.sales.get_status(order_id) == 0:
950950
self.db.sales.update_status(order_id, 1)
951951
self.db.sales.status_changed(order_id, 1)
952-
self.notification_listener.notify(unhexlify(buyer_guid), handle, "new order", order_id,
953-
title, image_hash)
952+
self.notification_listener.notify(unhexlify(buyer_guid), handle, "new order",
953+
order_id, title, image_hash)
954954

955955
notification = SMTPNotification(self.db)
956956
notification.send("[OpenBazaar] Payment for Order Received",

market/network.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636

3737
class Server(object):
38-
def __init__(self, kserver, signing_key, database):
38+
def __init__(self, kserver, signing_key, database, audit=True):
3939
"""
4040
A high level class for sending direct, market messages to other nodes.
4141
A node will need one of these to participate in buying and selling.
@@ -46,7 +46,7 @@ def __init__(self, kserver, signing_key, database):
4646
self.router = kserver.protocol.router
4747
self.db = database
4848
self.log = Logger(system=self)
49-
self.protocol = MarketProtocol(kserver.node, self.router, signing_key, database)
49+
self.protocol = MarketProtocol(kserver.node, self.router, signing_key, database, audit)
5050
task.LoopingCall(self.update_listings).start(3600, now=True)
5151

5252
def querySeed(self, list_seed_pubkey):

market/protocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
class MarketProtocol(RPCProtocol):
3030
implements(MessageProcessor)
3131

32-
def __init__(self, node, router, signing_key, database):
32+
def __init__(self, node, router, signing_key, database, audit=True):
3333
self.router = router
3434
self.node = node
3535
RPCProtocol.__init__(self, node, router)
3636
self.log = Logger(system=self)
37-
self.audit = Audit(db=database)
37+
self.audit = Audit(db=database, enabled=audit)
3838
self.multiplexer = None
3939
self.db = database
4040
self.signing_key = signing_key

openbazaard.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def run(*args):
4545
RESTPORT = args[4]
4646
WSPORT = args[5]
4747
HEARTBEATPORT = args[6]
48+
AUDIT = args[7]
4849

4950
def start_server(keys, first_startup=False):
5051
# logging
@@ -109,7 +110,7 @@ def on_bootstrap_complete(resp):
109110
protocol.register_processor(kserver.protocol)
110111

111112
# market
112-
mserver = network.Server(kserver, keys.signing_key, db)
113+
mserver = network.Server(kserver, keys.signing_key, db, AUDIT)
113114
mserver.protocol.connect_multiplexer(protocol)
114115
protocol.register_processor(mserver.protocol)
115116

@@ -247,6 +248,7 @@ def start(self):
247248
parser.add_argument('-r', '--restapiport', help="set the rest api port", default=18469)
248249
parser.add_argument('-w', '--websocketport', help="set the websocket api port", default=18466)
249250
parser.add_argument('-b', '--heartbeatport', help="set the heartbeat port", default=18470)
251+
parser.add_argument('-u', '--disableaudit', action='store_true', help="disable event logging")
250252
parser.add_argument('--pidfile', help="name of the pid file", default="openbazaard.pid")
251253
args = parser.parse_args(sys.argv[2:])
252254

@@ -262,11 +264,11 @@ def start(self):
262264
self.daemon.pidfile = "/tmp/" + args.pidfile
263265
self.daemon.start(args.testnet, args.loglevel, port, args.allowip,
264266
int(args.restapiport), int(args.websocketport),
265-
int(args.heartbeatport), time.time())
267+
int(args.heartbeatport), time.time(), args.disableaudit)
266268
else:
267269
run(args.testnet, args.loglevel, port, args.allowip,
268270
int(args.restapiport), int(args.websocketport),
269-
int(args.heartbeatport), time.time())
271+
int(args.heartbeatport), time.time(), args.disableaudit)
270272

271273
def stop(self):
272274
# pylint: disable=W0612

0 commit comments

Comments
 (0)