这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@dersimn
Copy link
Contributor

@dersimn dersimn commented Sep 14, 2017

At first sight this looks like a lot of changes to your code, but see this gist for a simple example.

if (typeof arguments[0] == 'string') {
	// preserves behaiviour in case of printf-like strings: "blabla count: %d - yeah!"
	// by just adding the timestamp to this string
	arguments[0] = prefix + " " + arguments[0];
	console.log.apply(console, arguments);
} else {
	// everything in here is exactly your unmodified code (except indentation).
	// ....
        var args = Array.prototype.slice.call(arguments);
	args.unshift(prefix);
	console.log.apply(console, args);
}

I stumbled upon this issue, when developing HS100toMQTT, where the original library allowed the use of an external logger for unified debugging output, but used console.log-typical strings for output (for e.g. this).

@hobbyquaker hobbyquaker merged commit 00bb4d6 into hobbyquaker:master Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants