Skip to content

Conversation

@jdnichollsc
Copy link
Contributor

PR Checklist

What is the current behavior?

Important logs don't accept other arguments.

What is the new behavior?

Allow passing arguments for important logs

Fixes/Implements/Closes #8657.

Thanks for your collaboration! <3

@cla-bot cla-bot bot added the cla: yes label Jun 27, 2021
@jdnichollsc jdnichollsc changed the title fix(log): Allow passing arguments for logs fix(log): Allow passing optional params for logs Jun 27, 2021
@farfromrefug
Copy link
Collaborator

@jdnichollsc awesome PR!

NathanWalker
NathanWalker previously approved these changes Jun 27, 2021
export function log(message: string, ...optionalParams: any[]): void {
if ((<any>global).__nslog) {
(<any>global).__nslog('CONSOLE LOG: ' + message);
(<any>global).__nslog('CONSOLE LOG: ' + message, ...optionalParams);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this passes through NSLog, not sure if we need to define an override (in the ios runtime) as mentioned here:
https://stackoverflow.com/a/42674570

@rigor789 may know?

The console.log below definitely makes sense and shouldn't be an issue but the __nslog, I'm not sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like here it's a single string arg: https://github.com/NativeScript/ns-v8ios-runtime/blob/master/AppWithModules/Frameworks/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers/TNSProcess.h#L27

@jdnichollsc did you try this running against latest @nativescript/ios 8.0.0? just curious if you found the optionalParams additions make it through the global.__nslog okay?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right! NSLog only works with one argument 🤦

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent thanks for updating!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're welcome!

@NathanWalker NathanWalker merged commit 7b80094 into NativeScript:master Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an option to print full log.

3 participants