this repo has no description
at fixPythonPipStalling 91 lines 3.7 kB view raw
1/* 2 * Copyright (c) 2018 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24#import <Foundation/Foundation.h> 25#import <EventFactory/EventFactory.h> 26 27#import "KernelEventMonitorParser.h" 28 29#define TokenStatus "status" 30#define TokenLinkStatus "linkStatus" 31#define TokenLinkQuality "linkQuality" 32 33@implementation KernelEventMonitorParser 34 35- (instancetype)init 36{ 37 NSArray<EFLogEventMatch *> *matches = @[ 38 [[EFLogEventMatch alloc] initWithPattern:@"Process interface (?<"TokenStatus">attach|detach): (?<"TokenInterfaceName">\\w+)" 39 newEventHandler: 40 ^EFEvent *(NSTextCheckingResult *matchResult, EFLogEvent *logEvent, BOOL *isComplete) { 41 *isComplete = YES; 42 EFNetworkControlPathEvent *newEvent = nil; 43 NSString *statusString = [logEvent substringForCaptureGroup:@TokenStatus inMatchResult:matchResult]; 44 if (statusString != nil) { 45 newEvent = [self createInterfaceEventWithLogEvent:logEvent matchResult:matchResult]; 46 if (newEvent != nil) { 47 newEvent.interfaceStatus = statusString; 48 } 49 } 50 return newEvent; 51 }], 52 [[EFLogEventMatch alloc] initWithPattern:@"Process interface link (?<"TokenLinkStatus">down|up): (?<"TokenInterfaceName">\\w+)" 53 newEventHandler: 54 ^EFEvent *(NSTextCheckingResult *matchResult, EFLogEvent *logEvent, BOOL *isComplete) { 55 *isComplete = YES; 56 EFNetworkControlPathEvent *newEvent = nil; 57 NSString *linkStatusString = [logEvent substringForCaptureGroup:@TokenLinkStatus inMatchResult:matchResult]; 58 if (linkStatusString != nil) { 59 newEvent = [self createInterfaceEventWithLogEvent:logEvent matchResult:matchResult]; 60 if (newEvent != nil) { 61 if ([linkStatusString isEqualToString:@"up"]) { 62 newEvent.link = @"link up"; 63 } else if ([linkStatusString isEqualToString:@"down"]) { 64 newEvent.link = @"link down"; 65 } else { 66 newEvent.link = linkStatusString; 67 } 68 } 69 } 70 return newEvent; 71 }], 72 [[EFLogEventMatch alloc] initWithPattern:@"Process interface quality: (?<"TokenInterfaceName">\\w+) \\(q=(?<"TokenLinkQuality">[-\\d]+)\\)" 73 newEventHandler: 74 ^EFEvent * _Nullable(NSTextCheckingResult * _Nonnull matchResult, EFLogEvent * _Nonnull logEvent, BOOL * _Nonnull isComplete) { 75 *isComplete = YES; 76 EFNetworkControlPathEvent *newEvent = nil; 77 NSString *qualityString = [logEvent substringForCaptureGroup:@TokenLinkQuality inMatchResult:matchResult]; 78 if (qualityString != nil) { 79 newEvent = [self createInterfaceEventWithLogEvent:logEvent matchResult:matchResult]; 80 if (newEvent != nil) { 81 newEvent.linkQuality = qualityString.integerValue; 82 } 83 } 84 return newEvent; 85 }], 86 ]; 87 EFLogEventParser *parser = [[EFLogEventParser alloc] initWithMatches:matches]; 88 return [super initWithCategory:@"KernelEventMonitor" eventParser:parser]; 89} 90 91@end