Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Added noMethodLog option #93

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Both `.provider()` and `.server()` take a single object which allows you to spec
* `"ws"`: Enable a websocket server. This is `true` by default.
* `"vmErrorsOnRPCResponse"`: Whether to report runtime errors from EVM code as RPC errors. This is `true` by default to replicate the error reporting behavior of previous versions of ganache.
* `"hdPath"`: The hierarchical deterministic path to use when generating accounts. Default: "m/44'/60'/0'/0/"
* `"noMethodLog"`: `boolean` - Do not output RPC method name.

# IMPLEMENTED METHODS

Expand Down
12 changes: 9 additions & 3 deletions lib/httpServer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var http = require("http");

module.exports = function (provider, logger) {
module.exports = function (provider, options) {
var server = http.createServer(function (request, response) {
var logger = options.logger;

var headers = request.headers;
var method = request.method;
Expand Down Expand Up @@ -43,14 +44,19 @@ module.exports = function (provider, logger) {
}

// Log messages that come into the TestRPC via http
var logIfNeed = function (message) {
if (options.noMethodLog === false) {
logger.log(message);
}
};
if (payload instanceof Array) {
// Batch request
for (var i = 0; i < payload.length; i++) {
var item = payload[ i ];
logger.log(item.method);
logIfNeed(item.method);
}
} else {
logger.log(payload.method);
logIfNeed(payload.method);
}

provider.send(payload, function (err, result) {
Expand Down
2 changes: 1 addition & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
var logger = options.logger;
var provider = new Provider(options);

var server = httpServer(provider, logger);
var server = httpServer(provider, options);

connectionCounter = 0;
connections = {};
Expand Down