I'm working on a logger that is based on Unified Logging System that supports activities/scopes and I've found that a message with fault level type is not captured by any of my activities:
var os_state = os_activity_scope_state_s()
let os_activity = _os_activity_create(dso, strdup("My Activity"), OS_ACTIVITY_CURRENT, OS_ACTIVITY_FLAG_DEFAULT)
os_activity_scope_enter(os_activity, &os_state)
os_log("fault message", type: .fault) // "My Activity" don't have one
os_activity_scope_leave(&os_state)
Later I found the activity with my message:
16:04:52.978940+0300 libsystem_trace.dylib 0 Activity for state dumps
So the system creates a special activity for that kind of messages (Tested on Mac/iOS).
But from the documentation (https://developer.apple.com/documentation/os/oslogtype/2320725-fault):
If an activity object exists, logging at this level captures information for the entire process chain.
And it's the same as for the error log level which is captured OK for custom activities.
Is a known issue or expected behaviour? I can't find any info about.
I am looking for a way to update the test socket test status (the color: Green, Yellow, Red etc) indicator while the test is running. What I am experiencing is that the red color would appear only at the end of the entire test sequence if any of the test steps fail. If any of the tests in any of the subsequences fail, I can see Red appear on the right side in status indicator for any particular steps however, I would like to know how to have the status of the Execution Annunciator updated during run time as opposed to at the end of the test. As the sequence execution pointer goes through various steps during it's hard to see what failed as the pointer moves to next step after execution. In sequences that run for a long period of time, I would like to know by looking at the socket status whether any of the steps failed rather than waiting till the end of the sequence.
I tried looking at the report but it scrolls down and makes it impossible to see if anything has failed so far...!
See the screenshot below:
Thank you,
When I run my UI Test suite from XCode, the logs I get are quite useful and consist almost entirely of information about the elements I'm trying to interact with and the elements on the screen.
When I run my UI Test suite with the keep-the-logs-around options using Fastlane, the log looks mostly like this:
13:52:03.660 xcodebuild[10946:917312] (LOG ARBITER) Rotating message buffer with 388 messages.
...
13:53:24.666 xcodebuild[10946:916508] (LOG ARBITER) Rotating message buffer with 825 messages.
13:53:26.514 xcodebuild[10946:917191] (LOG ARBITER) Dumping buffered message data; 21669 messages.
and the bits of the log that are actually around look something like this:
14:28:28.074 XCTRunner[10957:916546] <XCTWaiter: 0x608000011280> entering wait loop for 0.20s
14:28:28.166 XCTRunner[10957:926899] <XCTWaiter: 0x608000010470> watchdog first trigger, clearing _XCWaitLoopIsValid and waking other waiters
14:28:28.166 XCTRunner[10957:928326] <XCTWaiter: 0x608000010390> watchdog second trigger, weakWaiter: (null)
14:28:28.271 XCTRunner[10957:928326] <XCTWaiter: 0x6080000100d0> watchdog second trigger, weakWaiter: (null)
14:28:28.271 XCTRunner[10957:928386] <XCTWaiter: 0x60000001ee60> watchdog second trigger, weakWaiter: (null)
along with having the actual useful information that would appear as described above when run through xcode.
Is there some way that I can reduce the logging level of the logs so that I don't get all of this noise?
In a simple stateless service I am attempting to report health. As a test I am simply flipping between OK and Warning states on every iteration of my loop in RunAsync (it has a sleep interval of 15secs). The code looks like this:
// report warning on odd iterations
HealthState state = ((++iterations % 2) != 0) ? HealthState.Warning : HealthState.Ok;
HealthInformation health = new HealthInformation("ServiceCode", "Iteration", state);
Partition.ReportInstanceHealth(health);
I am logging the state on each iteration of the loop and the log shows it flipping back and forth. But in the SF Explorer it is stuck on Ok, never switching to Warning (I have a refresh interval of 5secs in SFExplorer).
What am I doing wrong here?
Try specifying HealthInformation.SequenceNumber with an incremental value for every state change.
Looks like health reporting is significantly slower than I would expect. Working on that 15sec interval was not enough time for it to show the alternating health state. Moving to a 30sec interval seems to have resolved it.
It's some kind of annoying:
Since I started using the MPMoviePlayerController the console is overfilled with information from MPAVController.
Eg:
[MPAVController] Autoplay: _streamLikelyToKeepUp: 1 -> 1
[MPAVController] Autoplay: Disabling autoplay
This is some kind of annoying because I always have to search for my own logged information.
Is there a way to turn off logging for specific objects or frameworks?
I don't think such filtering is possible out of the box. But it's possible to redirect stderr (which is used by NSLog) into a pipe, read from that pipe in a background thread and then print messages that pass through the filter onto stdout (which is captured by the debugger as well). This code does the job:
int main(int argc, char *argv[])
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void) {
size_t const BUFFER_SIZE = 2048;
// Create a pipe
int pipe_in_out[2];
if (pipe(pipe_in_out) == -1)
return;
// Connect the 'in' end of the pipe to the stderr
if (dup2(pipe_in_out[1], STDERR_FILENO) == -1)
return;
char *buffer = malloc(BUFFER_SIZE);
if (buffer == 0)
return;
for (;;)
{
// Read from the 'out' end of the pipe
ssize_t bytes_read = read(pipe_in_out[0], buffer, BUFFER_SIZE);
if (bytes_read <= 0)
break;
// Filter and print to stdout
if (should_show(buffer)) // TODO: Apply filters here
fwrite(buffer, 1, bytes_read, stdout);
}
free(buffer);
close(pipe_in_out[1]);
});
// Rest of main
}
Please note that this code is quite simple and doesn't handle all corner cases. First of all it captures all stderr output and not just NSLog. Maybe this could be filtered out by checking against the content. NSLog output always starts with the date and time.
Second problem with this code is that it doesn't try to split/join strings it reads from the pipe. There's no guarantee that there will be one NSLog per read. They could be coming together or be too long and would be split. To handle this it would require additional processing of the data read from the pipe.
Anyway, for many practical purposes this should be enough.
You should look into NSLogger. While NSLog doesn't give you any selectivity about what you see from run to run, NSLogger can. NSLogger displays output from the device (or simulator) in its own window in OS X.
Basically it adds the concept of facility and level to output. Unix wizards might find fault with this comparison but I see it as very similar to syslog. The NSLogger viewer lets you display output messages for one or more facilities (which you define) which also meet the minimum level required.
Macros define what you see in the output window. Here's an excerpt:
#ifdef DEBUG
#define LOG_GENERAL(level, ...) LogMessageF(__FILE__,__LINE__,__FUNCTION__,#"general",level,__VA_ARGS__)
#else
#define LOG_GENERAL(...) do{}while(0)
#endif
When DEBUG is off, no messages appear. When on, if you have a LOG_GENERAL() statement in code and your viewer is configured to display facility "general" and your level is sufficient to be displayed, you get a message.
It's incredibly flexible and I like it a lot. It takes about five minutes to add to your project. Please take a look at the github page linked above for full details and download.
(This will not solve the problem of MPAVController filling the console with messages, but it does put the messages you want in a new window, making it much easier to control, filter and interpret what you are interested in.)
Another option, if you can use it, is to run either a simulator or a device running iOS < 6.0.
The MPAVController log messages do not appear for me when using a 5.0 device or the 5.1 Simulator. But they definitely appear in the 6.0 Simulator.
Of course one should generally use the current OS, but if one is working on a video heavy section of a project, running an earlier simulator or device while working on that particular set of tasks is a way to alleviate this logging headache.
This also provides some backward compatibility testing as a bonus.