How can I direct messages from mac console.app to a log file?

I'm trying to complete a bash script to capture if an external webcam is active in a video conference session. Some users will switch the camera to the built-in MAC camera. When this happens I want to trigger a set of events.

Things tried: reviewed the console.app to look for patterns on when the switch occurs in a user test & discovered messages indicating when the facetime camera changes state. I found this

019-08-31 22:59:57.387405 -0500 AppleCameraInterface default 0 22:59:57.387405 -0500 kernel AppleCamIn::power_on_hardware

2019-08-31 22:59:57.814936 -0500 AppleCameraAssistant default 438 22:59:57.814936 -0500 AppleCameraAssistant StartHardwareStream: creating frame receiver: 1280 x 720 (420v) [12.00,30.00]fps

2019-08-31 22:59:59.679037 -0500 AppleCameraAssistant default 438 22:59:59.679037 -0500 AppleCameraAssistant StopHardwareStream 2019-08-31 22:59:59.809252 -0500 AppleCameraInterface default 0 22:59:59.809252 -0500 kernel AppleCamIn::power_off_hardware

I thought I could simply grep these message from the console.app but it seems to be easier said than done. I thought i could find the msgs in one of the console report files but When I look at the various reports on the console, i'm not finding a report that contains the messages above. How can I direct messages from console.app to a log file versus manually copying and pasting the info from the console?or point me to a direction? Am I missing something?

Like your question before, you can (or should be able to) get this information more easily from the system profiler (than using log files):

system_profiler

See summary man page here:

root#  system_profiler -usage
Usage: system_profiler [-listDataTypes]
       system_profiler [-xml] [-timeout n] [-detailLevel n]
       system_profiler [-xml] [-timeout n] [dataType1 ... dataTypeN]

  -detailLevel n    specifies the level of detail for the report
                      mini = short report (contains no identifying or personal information)
                      basic = basic hardware and network information
                      full = all available information

  -listDataTypes    lists all the available datatypes

  -xml              generates xml output instead of plain text
                    if redirected to a file with the extension ".spx"
                    the file can be opened in System Profiler.app

  -timeout          specifies the maximum time to spend gathering information
                    the default is 180 seconds, 0 means no timeout

  Redirect stderr to /dev/null to suppress progress and error messages.

Examples:

  system_profiler
     Generates a text report with the standard detail level.

  system_profiler -detailLevel mini
     Generates a short report without identifying/personal information.

  system_profiler -listDataTypes
     Shows a list of the available data types.

  system_profiler SPSoftwareDataType SPNetworkDataType
     Generates a text report containing only software and network data.

  system_profiler -xml >MySystem.spx
     Creates a XML file which can be opened by System Profiler.app
1 Like

Thanks Neo. I'm going to go back and review the system profiler and my results. I initially ran the system profiler full detail and did a search for this msg ( AppleCamIn: power\_on_hardware ) and others. Looking at the profiler output but didn't see it using find. This msg and others I listed appear when I'm switching the audio and video inputs during a video conference session.

Hey dallas88,

You should definitely see it enabled in the system_profiler output. Maybe try a few different system_profiler switches and system_profiler| grep -i "some keyword" searches to find it?

Please post back and let us know what you tried and what worked and what did not work.

Thanks!

I ran a few searches in the system profiler and seem to be finding more info as try grep - i with different keywords. I will review more to spot other patterns but the first keyword search didn't land what i was looking for,

dddd$ system_profiler| grep -i "StartHardwareStream.*"
2019-09-04 23:29:06.218 system_profiler[87624:9749498] SystemInfo-AccessoryFW from dict - Magic Keyboard with Numeric Keypad = 0x0084
2019-09-04 23:29:06.218 system_profiler[87624:9749498] SystemInfo-AccessoryFW from dict - Magic Trackpad 2 = 0x0062
2019-09-04 23:29:06.219 system_profiler[87624:9749498] SystemInfo-AccessoryFW from dict - Magic Trackpad 2 = 0x0062
2019-09-04 23:29:08.111 system_profiler[87625:9749507] Attempting to add source to main runloop, but the main thread as exited. This message will only log once. Break on _CFRunLoopError_MainThreadHasExited to debug.
2019-09-04 23:33:00.201 AllowPasswordPref[88030:9751089] error == Error Domain=com.apple.LocalAuthentication Code=-6 "Biometry is not available on this device." UserInfo={BiometryType=0, NSLocalizedDescription=Biometry is not available on this device.} isSupported ==  0
2019-09-04 23:33:00.201 AllowPasswordPref[88030:9751089] Hardware Check err == 0
2019-09-04 23:33:00.201 AllowPasswordPref[88030:9751089] Result -1
2019-09-04 23:33:01.894 AllowPasswordPref[88036:9751130] error == Error Domain=com.apple.LocalAuthentication Code=-6 "Biometry is not available on this device." UserInfo={BiometryType=0, NSLocalizedDescription=Biometry is not available on this device.} isSupported ==  0
2019-09-04 23:33:01.894 AllowPasswordPref[88036:9751130] Hardware Check err == 0
2019-09-04 23:33:01.894 AllowPasswordPref[88036:9751130] Result -1
2019-09-04 23:33:22.615 system_profiler[88128:9751465] SPUSBDevice: IOCreatePlugInInterfaceForService failed 0xe00002be

dddddd$ system_profiler| grep -i �camera�
   MassStorageCamera:
     Location: /System/Library/Image Capture/Devices/MassStorageCamera.app
   Type4Camera:
     Location: /System/Library/Image Capture/Devices/Type4Camera.app
   PTPCamera:
     Location: /System/Library/Image Capture/Devices/PTPCamera.app
2019-09-04 23:07:28.062 system_profiler[85082:9739521] SystemInfo-AccessoryFW from dict - Magic Keyboard with Numeric Keypad = 0x0084
2019-09-04 23:07:28.062 system_profiler[85082:9739521] SystemInfo-AccessoryFW from dict - Magic Trackpad 2 = 0x0062
2019-09-04 23:07:28.063 system_profiler[85082:9739521] SystemInfo-AccessoryFW from dict - Magic Trackpad 2 = 0x0062
2019-09-04 23:07:29.987 system_profiler[85083:9739526] Attempting to add source to main runloop, but the main thread as exited. This message will only log once. Break on _CFRunLoopError_MainThreadHasExited to debug.
Camera:
     Model ID: UVC Camera VendorID_9665 ProductID_12
   FaceTime HD Camera (Built-in):
     Model ID: UVC Camera VendorID_1452 ProductID_34065
     Description: Simulates a camera lens flare effect.
   AppleCameraInterface:
     Bundle ID: com.apple.driver.AppleCameraInterface
     Get Info String: AppleCameraInterface, Copyright © 2011 Apple Inc. All rights reserved.
     Location: /System/Library/Extensions/AppleCameraInterface.kext
   | |   |   | +-o FaceTime HD Camera (Built-in)@14400000  <class IOUSBHostDevice, id 0x100000316, registered, matched, active, busy 0 (13 ms), retain 25>
   | |   |   |   |   �USB Product Name� = �FaceTime HD Camera (Built-in)�
   | |   |   |   +-o FaceTime HD Camera (Built-in)@0  <class IOUSBHostInterface, id 0x100000369, registered, matched, active, busy 0 (1 ms), retain 7>
     | |   +-o FaceTime HD Camera (Built-in)@14400000  <class AppleUSBDevice, id 0x100000340, registered, matched, active, busy 0 (7 ms), retain 20>
     | |   | |   �USB Product Name� = �FaceTime HD Camera (Built-in)�
     | |   | +-o FaceTime HD Camera (Built-in)@0  <class AppleUSBInterface, id 0x10000036c, registered, matched, active, busy 0 (2 ms), retain 27>
     | |   | | |   �USB Interface Name� = �FaceTime HD Camera (Built-in)�
       allowCamera:
2019-09-04 23:11:20.453 AllowPasswordPref[85500:9741184] error == Error Domain=com.apple.LocalAuthentication Code=-6 �Biometry is not available on this device.� UserInfo={BiometryType=0, NSLocalizedDescription=Biometry is not available on this device.} isSupported ==  0
2019-09-04 23:11:20.454 AllowPasswordPref[85500:9741184] Hardware Check err == 0
2019-09-04 23:11:20.454 AllowPasswordPref[85500:9741184] Result -1
2019-09-04 23:11:22.198 AllowPasswordPref[85506:9741221] error == Error Domain=com.apple.LocalAuthentication Code=-6 �Biometry is not available on this device.� UserInfo={BiometryType=0, NSLocalizedDescription=Biometry is not available on this device.} isSupported ==  0
2019-09-04 23:11:22.198 AllowPasswordPref[85506:9741221] Hardware Check err == 0
2019-09-04 23:11:22.198 AllowPasswordPref[85506:9741221] Result -1
   allowCamera = 1;
   iPhone 9,4 backtelephotocamera:
   iPad 8,3 backcamera:
   iPad 8,7 backcamera:
   iPhone 10,1 back camera:
   iPad 7,3 backcamera:
   iPhone 11,8 backcamera:
   iPhone 10,3 backcamera:
   iPad 8,4 backcamera:
   iPad 8,8 backcamera:
   iPhone 10,2 back telephoto camera:
   iPhone 9,1 backcamera:
   iPad 8,1 backcamera:
   iPhone 10,3 backtelephotocamera:
   iPhone SE backcamera:
   iPad 7,1 backcamera:
   iPhone 10,2 back camera:
   iPad Pro (9.7-inch) backcamera:
   iPhone 6s backcamera:
   iPad 8,2 backcamera:
   iPad 8,6 backcamera:
   iPhone 9,3 backcamera:
   iPhone 6s Plus backcamera:
   iPhone 9,4 backcamera:
2019-09-04 23:11:41.905 system_profiler[85561:9741516] SPUSBDevice: IOCreatePlugInInterfaceForService failed 0xe00002be
       FaceTime HD Camera (Built-in):

 
ddddd$ system_profiler| grep -i "AppleCamIn.*"
2019-09-05 00:01:09.783 system_profiler[91360:9764618] SystemInfo-AccessoryFW from dict - Magic Keyboard with Numeric Keypad = 0x0084
2019-09-05 00:01:09.785 system_profiler[91360:9764618] SystemInfo-AccessoryFW from dict - Magic Trackpad 2 = 0x0062
2019-09-05 00:01:09.786 system_profiler[91360:9764618] SystemInfo-AccessoryFW from dict - Magic Trackpad 2 = 0x0062
2019-09-05 00:01:11.662 system_profiler[91361:9764626] Attempting to add source to main runloop, but the main thread as exited. This message will only log once. Break on _CFRunLoopError_MainThreadHasExited to debug.
2019-09-05 00:04:46.183 AllowPasswordPref[91862:9766511] error == Error Domain=com.apple.LocalAuthentication Code=-6 "Biometry is not available on this device." UserInfo={BiometryType=0, NSLocalizedDescription=Biometry is not available on this device.} isSupported ==  0
2019-09-05 00:04:46.183 AllowPasswordPref[91862:9766511] Hardware Check err == 0
2019-09-05 00:04:46.183 AllowPasswordPref[91862:9766511] Result -1
2019-09-05 00:04:47.970 AllowPasswordPref[91868:9766550] error == Error Domain=com.apple.LocalAuthentication Code=-6 "Biometry is not available on this device." UserInfo={BiometryType=0, NSLocalizedDescription=Biometry is not available on this device.} isSupported ==  0
2019-09-05 00:04:47.970 AllowPasswordPref[91868:9766550] Hardware Check err == 0
2019-09-05 00:04:47.970 AllowPasswordPref[91868:9766550] Result -1
2019-09-05 00:05:07.525 system_profiler[91923:9766828] SPUSBDevice: IOCreatePlugInInterfaceForService failed 0xe00002be

Thanks.

It looks like the level of detail you are looking for is not available in system_profiler and you may have no choice but to use the logfiles (syslog) as you were doing (indirectly via console.app).

Console.app automatically shows system.log , and other log files, so you don't need to redirect entries from console.app but you need to find the (syslog) file which console.app used.

Make sense?

Example:

/var/log/system.log

You can monitor it easily using tail -f /var/log/system.log

Reference: see also the "logger" ( man logger ) and "syslog" ( man syslog ).

Please post back with the details of which log file you found had the information you need.

Thanks.

This might not the best method but I used the Log show command to access the unified logs.
And then directed this to a file. So I use this to monitor the camera status.

#!/bin/bash
# Detects the status of the Apple Camera (Facetime).
Camstatus=$(log show --last 15m | grep 'AppleCamIn::')
echo "$Camstatus" >>~/library/logs/camera.log

I found out I can also can also run this command to collect the log info.
sudo log collect --output ~/Documents/logcoll.logarchive --start '2020-02-10'
(softron
HOW TO: Collect system logs on macOS Sierra and later � Softron Support Desk

I saw this post from @jollyRoger on the command to open the .logarchive formatted file.
Unified Logs | macOS High Sierra - Ask Different

Sorry I forgot to post back my gratitude for this great forum. Thanks Neo
Thanks, Ron -- still learning.

1 Like