I want to use the OSLog activities to structure my logs but I stuck with a problem of absence needed activity constants on Swift such as OS_ACTIVITY_CURRENT
and OS_ACTIVITY_NONE
and I have an error when I try to create an activity:
let activity = _os_activity_create(dso, strdup(name),
OS_ACTIVITY_CURRENT, // Error: Static member 'OS_ACTIVITY_CURRENT' cannot be used on instance of type 'OSLogOutput'
OS_ACTIVITY_FLAG_DEFAULT)
os.activity
framework has descriptions of activity constants without any definitions (but defines the activity flags OS_ACTIVITY_FLAG_DEFAULT
, OS_ACTIVITY_FLAG_DETACHED
, OS_ACTIVITY_FLAG_IF_NONE_PRESENT
):
/*!
* @const OS_ACTIVITY_CURRENT
*
* @discussion
* Create activity and links to the current activity if one is present.
* If no activity is present it is treated as if it is detached.
*/
If we look in ObjC headers <os/activity.h>
we can find these constants:
#define OS_ACTIVITY_NONE OS_OBJECT_GLOBAL_OBJECT(os_activity_t, _os_activity_none)
#define OS_ACTIVITY_CURRENT OS_OBJECT_GLOBAL_OBJECT(os_activity_t, _os_activity_current)
It looks like that OSLog is limited on Swift so how to work with OSLog activities or where can I find the constants?