Get logs for a specific log group
775105
def log_entries_from_group(session, group_name, start, end):
    ''''''
    logs = session.client('logs')
    log.info("Fetching logs from group: %s" % group_name)
    try:
        logs.describe_log_groups(logGroupNamePrefix=group_name)
    except ClientError as e:
        if e.response['Error']['Code'] == 'ResourceNotFoundException':
            return
        raise
    try:
        log_streams = logs.describe_log_streams(
            logGroupName=group_name,
            orderBy="LastEventTime",
            limit=3,
            descending=True,
        )
    except ClientError as e:
        if e.response['Error']['Code'] == 'ResourceNotFoundException':
            return
        raise
    start = _timestamp_from_string(start)
    end = _timestamp_from_string(end)
    for s in reversed(log_streams['logStreams']):
        result = logs.get_log_events(
            logGroupName=group_name,
            logStreamName=s['logStreamName'],
            startTime=start,
            endTime=end,
        )
        for e in result['events']:
            yield e
515333
def get_log_report(log: Union[logging.Logger,
                              logging.PlaceHolder]) -> Dict[str, Any]:
    
    if isinstance(log, logging.Logger):
        # suppress invalid error for Logger.manager:
        # noinspection PyUnresolvedReferences
        return {
            '(object)': str(log),
            'level': log.level,
            'disabled': log.disabled,
            'propagate': log.propagate,
            'parent': str(log.parent),
            'manager': str(log.manager),
            'handlers': [get_handler_report(h) for h in log.handlers],
        }
    elif isinstance(log, logging.PlaceHolder):
        return {
            "(object)": str(log),
        }
    else:
        raise ValueError("Unknown object type: {!r}".format(log))
1212392
def logs(self):
        """"""
        if not self.parent.loaded: self.parent.load()
        logs = self.parent.p.logs_dir.flat_directories
        logs.sort(key=lambda x: x.mod_time)
        return logs
1328749
def get_registered_loggers(hide_children=False, hide_reusables=False):
    

    return [logger for logger in logging.Logger.manager.loggerDict.keys()
            if not (hide_reusables and "reusables" in logger)
            and not (hide_children and "." in logger)]
1257389
def getCommissioningLogs(self):
        
        rawLogs = self.logThread.get()
        ProcessedLogs = []
        payload = []
        while not rawLogs.empty():
            rawLogEach = rawLogs.get()
            print rawLogEach
            if "[THCI]" not in rawLogEach:
                continue

            EncryptedPacket = PlatformDiagnosticPacket()
            infoList = rawLogEach.split('[THCI]')[1].split(']')[0].split('|')
            for eachInfo in infoList:
                print eachInfo
                info = eachInfo.split("=")
                infoType = info[0].strip()
                infoValue = info[1].strip()
                if "direction" in infoType:
                    EncryptedPacket.Direction = PlatformDiagnosticPacket_Direction.IN if 'recv' in infoValue \
                        else PlatformDiagnosticPacket_Direction.OUT if 'send' in infoValue \
                        else PlatformDiagnosticPacket_Direction.UNKNOWN
                elif "type" in infoType:
                    EncryptedPacket.Type = PlatformDiagnosticPacket_Type.JOIN_FIN_req if 'JOIN_FIN.req' in infoValue \
                        else PlatformDiagnosticPacket_Type.JOIN_FIN_rsp if 'JOIN_FIN.rsp' in infoValue \
                        else PlatformDiagnosticPacket_Type.JOIN_ENT_req if 'JOIN_ENT.ntf' in infoValue \
                        else PlatformDiagnosticPacket_Type.JOIN_ENT_rsp if 'JOIN_ENT.rsp' in infoValue \
                        else PlatformDiagnosticPacket_Type.UNKNOWN
                elif "len" in infoType:
                    bytesInEachLine = 16
                    EncryptedPacket.TLVsLength = int(infoValue)
                    payloadLineCount = (int(infoValue) + bytesInEachLine - 1)/bytesInEachLine
                    while payloadLineCount > 0:
                        payloadLineCount = payloadLineCount - 1
                        payloadLine = rawLogs.get()
                        payloadSplit = payloadLine.split('|')
                        for block in range(1, 3):
                            payloadBlock = payloadSplit[block]
                            payloadValues = payloadBlock.split(' ')
                            for num in range(1, 9):
                                if ".." not in payloadValues[num]:
                                    payload.append(int(payloadValues[num], 16))

                    EncryptedPacket.TLVs = PlatformPackets.read(EncryptedPacket.Type, payload) if payload != [] else []

            ProcessedLogs.append(EncryptedPacket)
        return ProcessedLogs
495620
public static List<CallLogEntry> getAllLogsOfDuration(List<CallLogEntry> logs, int duration, boolean greaterthan) {
		List<CallLogEntry> list = new ArrayList<CallLogEntry>();
		for(CallLogEntry log : logs) {
			if(log.duration<duration ^ greaterthan) {
			    list.add(log);
			}
		}
		return list;
	}
141812
def runlogs_policy(log_group_ref):
    """"""
    p = Policy(
        Statement=[
            Statement(
                Effect=Allow,
                Resource=[
                    Join('', [
                        'arn:aws:logs:*:*:log-group:',
                        log_group_ref,
                        ':log-stream:*'])],
                Action=[
                    logs.CreateLogStream,
                    logs.PutLogEvents,
                ])])
    return p
717181
def get_logs(self):
        ''''''
        folder = os.path.dirname(self.pcfg['log_file'])
        for path, dir, files in os.walk(folder):
            for file in files:
                if os.path.splitext(file)[-1] == '.log':
                    yield os.path.join(path, file)
243144
def fetch_group(group_id, failures=True, wait=0, count=None, cached=Conf.CACHED):
    
    if cached:
        return fetch_group_cached(group_id, failures, wait, count)
    start = time()
    if count:
        while True:
            if count_group(group_id) == count or wait and (time() - start) * 1000 >= wait >= 0:
                break
            sleep(0.01)
    while True:
        r = Task.get_task_group(group_id, failures)
        if r:
            return r
        if (time() - start) * 1000 >= wait >= 0:
            break
        sleep(0.01)
174354
def filter_log_events(awsclient, log_group_name, start_ts, end_ts=None):
    
    client_logs = awsclient.get_client('logs')
    # TODO use all_pages instead!
    logs = []
    next_token = None
    while True:
        request = {
            'logGroupName': log_group_name,
            'startTime': start_ts
        }
        if end_ts:
            request['endTime'] = end_ts
        if next_token:
            request['nextToken'] = next_token
        response = client_logs.filter_log_events(**request)
        logs.extend(
            [{'timestamp': e['timestamp'], 'message': e['message']}
             for e in response['events']]
        )
        if 'nextToken' not in response:
            break
        next_token = response['nextToken']
    return logs
477963
def logs(self):
        """"""
        url = self._url + "/logs"
        return _log(url=url,
                    securityHandler=self._securityHandler,
                    proxy_url=self._proxy_url,
                    proxy_port=self._proxy_port)
122923
def filter(self, record):
        """"""
        fmt = LogManager.spec.context_format
        if fmt:
            data = self.context.to_dict()
            if data:
                record.context = fmt % ",".join("%s=%s" % (key, val) for key, val in sorted(data.items()) if key and val)
            else:
                record.context = ""
        return True
125113
def get_logs(self, login=None, **kwargs):
        

        _login = kwargs.get(
            'login',
            login
        )
        log_events_url = GSA_LOGS_URL.format(login=_login)
        return self._request_api(url=log_events_url).json()
1119821
def log(self):
        '''
        
        '''

        log = self._log(num=10, format='%h::%b').get('stdout')
        if log:
            return [
                dict(commit=c, message=m) for c, m in [
                    l.split('::') for l in log
                ]
            ]
851216
def process_log_event(event, context):
    """"""
    init()
    serialized = event['awslogs'].pop('data')
    data = json.loads(zlib.decompress(
        base64.b64decode(serialized), 16 + zlib.MAX_WBITS))

    # Fetch additional logs for context (20s window)
    timestamps = [e['timestamp'] for e in data['logEvents']]
    start = min(timestamps) - 1000 * 15
    end = max(timestamps) + 1000 * 5

    events = logs.get_log_events(
        logGroupName=data['logGroup'],
        logStreamName=data['logStream'],
        startTime=start,
        endTime=end,
        startFromHead=True)['events']

    message = [
        "An error was detected",
        "",
        "Log Group: %s" % data['logGroup'],
        "Log Stream: %s" % data['logStream'],
        "Log Owner: %s" % data['owner'],
        "",
        "Log Contents",
        ""]

    # We may get things delivered from log sub that are not in log events
    for evt in data['logEvents']:
        if evt not in events:
            events.append(evt)

    for evt in events:
        message.append(message_event(evt))
        message.append("")

    params = dict(
        TopicArn=config['topic'],
        Subject=config['subject'],
        Message='\n'.join(message))

    sns.publish(**params)
1225248
def get_event_logs_by_request_id(self, request_id):
        

        # Get all relevant event logs
        unfiltered_logs = self._get_cci_event_logs() + self._get_security_group_event_logs()

        # Grab only those that have the specific request id
        filtered_logs = []

        for unfiltered_log in unfiltered_logs:
            try:
                metadata = json.loads(unfiltered_log['metaData'])
                if 'requestId' in metadata:
                    if metadata['requestId'] == request_id:
                        filtered_logs.append(unfiltered_log)
            except ValueError:
                continue

        return filtered_logs
1322910
def get_next_logs(self, n):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.ResourceList.get_next_resources
        if n > self.available():
            # !!! This is not quite as specified (see method docs) !!!
            raise IllegalState('not enough elements available in this list')
        else:
            next_list = []
            i = 0
            while i < n:
                try:
                    next_list.append(next(self))
                except StopIteration:
                    break
                i += 1
            return next_list