-
Notifications
You must be signed in to change notification settings - Fork 153
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
Wrong (different) thread id in logs depending on XcodeLogConfiguration init options #72
Comments
Thanks a lot for detailed report. To answer your question, the thread ID should show the ID of the thread that issues the call to How the thread ID is constructed when using the
The reason for this is that the When It is possible that this accounts for the discrepancy. Are the thread IDs consistent if you pass |
I haven't tried to pass Like I said I have made a minimal app, there is no other custom code in the template app beside the one I have provided. I have tried it on iPhone 5 on iOS 10, I will try to play around with it a bit more, but so far it seems that the output of the default configuration is not correct. As you see |
If that's the case then it's a bug / oversight on my part. |
I've looked into it further and, the interesting thing is, the correct thread ID is rendered by CleanroomLogger. In your first case, the (incorrect) thread ID is generated by Apple's In your second case, the (correct) thread ID is created by CleanroomLogger. I'm not sure if that means Apple's var threadID: UInt64 = 0
pthread_threadid_np(nil, &threadID) This is definitely a head-scratcher. |
Well, I have dug into code a little bit more. What causes it is this: Minimum severity as in my initial report doesn't matter. but if you do the same in which means that the os_log would generate the 'header' with date and app details. Thus it will use the CleanroomLogger serial queue id to print the message. This is the queue to which all messages are dispatched and it differs from main queue and global queue in which log message was dispatch by the application's code. I would say that the correct way to log messages is to generate the message for OSLogRecorder from the saved of LogEntry which would include the correct thread ID. In the end of the day I would want to know the thread ID of the thread in which I called log function not the thread ID of the logger process. |
Hey, I have encountered a pretty interesting bug.
This is my setup:
Empty new project from single view template. Code added in AppDelegate.swift
This code:
produces this output:
This code:
produces this output:
Please note the thread IDs in both cases.
In the first case NSLog in main thread, NSLog in global queue and CleanroomLogger logs show different IDs.
In the second case dispatched and non dispatched logs (both CleanroomLogger and NSLog) show similar (correct if you ask me) thread IDs.
Apparently there is a bug somewhere which causes incorrect threadID printing or capturing behaviour.
On a side note there is a good question: which threadID should log show?
I would say the first.
The text was updated successfully, but these errors were encountered: