Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stringify(object) dynamically?... #12

Closed
ferdly opened this issue Nov 29, 2016 · 2 comments
Closed

stringify(object) dynamically?... #12

ferdly opened this issue Nov 29, 2016 · 2 comments

Comments

@ferdly
Copy link

ferdly commented Nov 29, 2016

First: thank you, Thank You, THANK YOU!

Already making me so much more productive.

Also, I am calling this an 'Issue' only in that I am inferring that everything Logger can do you intend BetterLog to handle. Disregard/Delete if my inference is incorrect.

Running this code:

var a = 7;
var b = 9;
var c {firstDog: "Chester", 
secondDog: "Marais"};

Logger.log("You can inject variables with %s, every time you place %s in this string the next variable of the following parameters will be logged. For the last variable %s will format the object as a string", a, b, c);

...will 'stringify' the object on the fly. But if I call the same code with BetterLog it renders only
"[object Object]" for the placeholder.

However, running this code:

var a = 7;
var b = 9;
var c {firstDog: "Chester", 
secondDog: "Marais"};
var c_string = JSON.stringify(c);

Logger.log("You can inject variables with %s, every time you place %s in this string the next variable of the following parameters will be logged. For the last variable %s will format the object as a string", a, b, c_string);

... works exactly as expected using BetterLog. Not too much more trouble, and all of the amazing ways that BetterLog is indeed better out-weighs this. But I thought you might like the feedback to make BetterLog even better.
Regards,

@peterherrmann
Copy link
Owner

Thanks for reporting the issue @ferdly, I have reproduced your issue. I will have a look at a fix.

Cheers,
Peter

@rupertleveneucd
Copy link

Should this be reopened? In version 27 objects are logged as [object Object] in the spreadsheet for me.

Logger=BetterLog.useSpreadsheet('KeyKeyKey');
function test() {
  Logger.log("string");
  Logger.log({"key":1});
}

Spreadsheet output:

2020-07-10 08:10:02:231 +0100 003348 INFO string
2020-07-10 08:10:03:325 +0100 004442 INFO [object Object]

The stackdriver log has those lines as well as the stringified output (final line):

Jul 10, 2020, 8:10:02 AM	Info	2020-07-10 08:10:02:223 +0100 003340 INFO string
Jul 10, 2020, 8:10:02 AM	Info	string
Jul 10, 2020, 8:10:03 AM	Info	2020-07-10 08:10:03:317 +0100 004434 INFO [object Object]
Jul 10, 2020, 8:10:03 AM	Info	{ key: 1 }

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

No branches or pull requests

3 participants