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

Commit

Permalink
Merge pull request #500 from cpacia/master
Browse files Browse the repository at this point in the history
Add cmd line flag to disable audit log
  • Loading branch information
cpacia committed Nov 11, 2016
2 parents 09c108c + 87c7189 commit 903ac7f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
5 changes: 4 additions & 1 deletion market/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ class Audit(object):
A class for handling audit information
"""

def __init__(self, db):
def __init__(self, db, enabled=True):
self.db = db
self.enabled = enabled

self.log = Logger(system=self)

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

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

if action_id in self.action_ids:
Expand Down
4 changes: 2 additions & 2 deletions market/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,8 @@ def payment_received(self):
if self.db.sales.get_status(order_id) == 0:
self.db.sales.update_status(order_id, 1)
self.db.sales.status_changed(order_id, 1)
self.notification_listener.notify(unhexlify(buyer_guid), handle, "new order", order_id,
title, image_hash)
self.notification_listener.notify(unhexlify(buyer_guid), handle, "new order",
order_id, title, image_hash)

notification = SMTPNotification(self.db)
notification.send("[OpenBazaar] Payment for Order Received",
Expand Down
4 changes: 2 additions & 2 deletions market/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


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

def querySeed(self, list_seed_pubkey):
Expand Down
4 changes: 2 additions & 2 deletions market/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
class MarketProtocol(RPCProtocol):
implements(MessageProcessor)

def __init__(self, node, router, signing_key, database):
def __init__(self, node, router, signing_key, database, audit=True):
self.router = router
self.node = node
RPCProtocol.__init__(self, node, router)
self.log = Logger(system=self)
self.audit = Audit(db=database)
self.audit = Audit(db=database, enabled=audit)
self.multiplexer = None
self.db = database
self.signing_key = signing_key
Expand Down
8 changes: 5 additions & 3 deletions openbazaard.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def run(*args):
RESTPORT = args[4]
WSPORT = args[5]
HEARTBEATPORT = args[6]
AUDIT = args[7]

def start_server(keys, first_startup=False):
# logging
Expand Down Expand Up @@ -109,7 +110,7 @@ def on_bootstrap_complete(resp):
protocol.register_processor(kserver.protocol)

# market
mserver = network.Server(kserver, keys.signing_key, db)
mserver = network.Server(kserver, keys.signing_key, db, AUDIT)
mserver.protocol.connect_multiplexer(protocol)
protocol.register_processor(mserver.protocol)

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

Expand All @@ -262,11 +264,11 @@ def start(self):
self.daemon.pidfile = "/tmp/" + args.pidfile
self.daemon.start(args.testnet, args.loglevel, port, args.allowip,
int(args.restapiport), int(args.websocketport),
int(args.heartbeatport), time.time())
int(args.heartbeatport), time.time(), args.disableaudit)
else:
run(args.testnet, args.loglevel, port, args.allowip,
int(args.restapiport), int(args.websocketport),
int(args.heartbeatport), time.time())
int(args.heartbeatport), time.time(), args.disableaudit)

def stop(self):
# pylint: disable=W0612
Expand Down

0 comments on commit 903ac7f

Please sign in to comment.