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

fmt, log: messages are not appearing on device log for darwin/arm,arm64 #12194

Closed
rakyll opened this issue Aug 19, 2015 · 10 comments
Closed

fmt, log: messages are not appearing on device log for darwin/arm,arm64 #12194

rakyll opened this issue Aug 19, 2015 · 10 comments

Comments

@rakyll
Copy link
Contributor

rakyll commented Aug 19, 2015

Update the x/mobile/example/basic.main to fmt.Println and log.Println.

...
func main() {
    fmt.Println("starting")
    log.Println("log starting")
...

Build and deploy the app to the device. Run idevicesyslog, launch the app.

The expected result is to see "starting" and "log starting messages" to appear, even though there is no output from the example app.

/cc @crawshaw @hyangah @nigeltao

@nigeltao
Copy link
Contributor

Is it easy for you to check if those messages appear on Android instead of iOS?

@crawshaw
Copy link
Member

On android we redirect stdout and stderr to logd (the system logger) because there is no way to get access to an app's stdout for debugging on a non-root android phone, the usual development environment.

But that's not so on iOS, where stdout and stderr fit neatly with starting an app from inside Xcode. The attached lldb picks them up and drops them neatly in the output window, interleaved correctly with results from NSLog.

So redirecting os.Stdout and os.Stderr as we do for android would be consistent but an unpleasant development experience, so I think the inconsistency is worth it.

For the log package, there's a question: should we mirror the output to the system log? (We can do so quite easily by calling log.SetOutput(io.MultiWriter(os.Stdout, ...)).) I think we should match the behavior of NSLog here. Does it go to both?

@hyangah
Copy link
Contributor

hyangah commented Aug 19, 2015

NSLog writes to ASL. ASL provides an option to write the same log to stderr. (man asl_open)

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/13703 mentions this issue.

@rakyll
Copy link
Contributor Author

rakyll commented Aug 21, 2015

Are you sure that it is working? I can't see any log output.

$ go version
go version devel +b733234 Thu Aug 20 12:13:41 2015 +0000 darwin/amd64

@rakyll rakyll reopened this Aug 21, 2015
@crawshaw
Copy link
Member

I tested that a log.Printf line in example/basic appeared in the output of idevicesyslog, both starting from lldb and starting the app by clicking on the icon. What are you testing?

(Note that fmt.Printf will not appear in idevicesyslog, as per my comment earlier on this issue.)

@rakyll
Copy link
Contributor Author

rakyll commented Aug 24, 2015

I unfortunately can't see the log.Printf output on my device log by starting app by clicking on the icon. This is the main function I am testing:

func main() {
    log.Printf("-----main called")

    //...
}

Do you need any additional information about my device?

@crawshaw
Copy link
Member

Does your app import x/mobile/app?
Have you synced x/mobile past golang/mobile@ab223cf?

As this is a low priority issue, without a way to reproduce this I don't expect to get to this soon.

@rakyll
Copy link
Contributor Author

rakyll commented Aug 24, 2015

I must have had an ASL faulty. I rebooted the device and I can see the messages are appearing on the log. Thanks.

@rakyll rakyll closed this as completed Aug 24, 2015
@rakyll
Copy link
Contributor Author

rakyll commented Aug 24, 2015

For anyone who comes across the same problem of not being able to see the logs, note that you need to relaunch idevicesyslog every time you launch a new application on the device.

@golang golang locked and limited conversation to collaborators Aug 24, 2016
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
Fixes golang/go#12194

Change-Id: I9ff771336996c19ca43da56e3f8944e79c980a2b
Reviewed-on: https://go-review.googlesource.com/13703
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
Fixes golang/go#12194

Change-Id: I9ff771336996c19ca43da56e3f8944e79c980a2b
Reviewed-on: https://go-review.googlesource.com/13703
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants