Example #1
0
def DecompressTraceV3Log(input_path, output_path):
    try:
        with open(input_path, 'rb') as trace_file:
            with open(output_path, 'wb') as out_file:
                return UnifiedLogLib.DecompressTraceV3(trace_file, out_file)
    except:
        logger.exception('')
Example #2
0
    def ReadDscFiles(self, uuidtext_folder_path):
        '''Reads the dsc files.

        Args:
          uuidtext_folder_path (str): path of the uuidtext folder.
        '''
        self._caches = UnifiedLogLib.CachedFiles(self._vfs)
        self._uuidtext_folder_path = uuidtext_folder_path

        self._caches.ParseFolder(self._uuidtext_folder_path)
Example #3
0
    def ReadTimesyncFolder(self, timesync_folder_path):
        '''Reads the timesync folder.

        Args:
          timesync_folder_path (str): path of the timesync folder.

        Returns:
          bool: True if successful or False otherwise.
        '''
        self._ts_list = []

        UnifiedLogLib.ReadTimesyncFolder(
            timesync_folder_path, self._ts_list, self._vfs)

        return bool(self._ts_list)
Example #4
0
    def WriteLogEntry(self, log):
        '''Writes a Unified Log entry.

        Args:
          log (???): log entry:
        '''
        if self._connection:
            log[3] = UnifiedLogLib.ReadAPFSTime(log[3])
            log[18] = '{0!s}'.format(log[18])
            log[19] = '{0!s}'.format(log[19])

            # TODO: cache queries to use executemany
            try:
                cursor = self._connection.cursor()
                cursor.execute(self._INSERT_LOGS_VALUES_QUERY, log)

            except sqlite3.Error:
                logger.exception('Error inserting data into database')
Example #5
0
    def WriteLogEntry(self, log):
        '''Writes a Unified Log entry.

        Args:
          log (???): log entry:
        '''
        if self._file_object:
            log[3] = UnifiedLogLib.ReadAPFSTime(log[3])

            try:
                if self._mode == 'TSV_ALL':
                    log[18] = '{0!s}'.format(log[18]).upper()
                    log[19] = '{0!s}'.format(log[19]).upper()

                    self._file_object.write(
                        ('{}\t0x{:X}\t{}\t{}\t0x{:X}\t{}\t0x{:X}\t0x{:X}\t{}\t'
                         '{}\t{}\t({})\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t'
                         '{}\n').format(log[0], log[1], log[2], log[3], log[4],
                                        log[5], log[6], log[7], log[8], log[9],
                                        log[10], log[11], log[12], log[13],
                                        log[14], log[15], log[16], log[17],
                                        log[18], log[19], log[20], log[21],
                                        log[22]))

                else:
                    signpost = ''  # (log[15] + ':') if log[15] else ''
                    if log[15]:
                        signpost += '[' + log[16] + ']'
                    msg = (signpost + ' ') if signpost else ''
                    msg += log[11] + ' ' + (
                        ('(' + log[12] + ') ') if log[12] else '')
                    if len(log[13]) or len(log[14]):
                        msg += '[' + log[13] + ':' + log[14] + '] '
                    msg += log[22]

                    self._file_object.write(
                        ('{time} {li[4]:<#10x} {li[5]:11} {li[6]:<#20x} '
                         '{li[8]:<6} {li[10]:<4} {message}\n').format(
                             li=log,
                             time=log[3],
                             message=msg.replace('\n', ',')))

            except (IOError, OSError):
                logger.exception('Error writing to output file')
Example #6
0
 def dumpLogToStdout(self, logs, tracev3):
     for log in logs:
         t0 = UnifiedLogLib.ReadAPFSTime(log[3])
         signpost = ''  # (log[15] + ':') if log[15] else ''
         if log[15]:
             signpost += '[' + log[16] + ']'
         msg = (signpost + ' ') if signpost else ''
         msg += log[11] + ' ' + (('(' + log[12] + ') ') if log[12] else '')
         if len(log[13]) or len(log[14]):
             msg += '[' + log[13] + ':' + log[14] + '] '
         msg += log[22]
         # self._file_object.write((
         #     '{time} {li[4]:<#10x} {li[5]:11} {li[6]:<#20x} '
         #     '{li[8]:<6} {li[10]:<4} {message}\n').format(
         #         li=log, time=log[3], message=msg))
         print(
             f'{t0} {log[4]:<#10x} {log[5]:11} {log[6]:<#20x} {log[8]:<6} {log[10]:<4} {msg}'
         )
     pass