Loads a log dump from the string |logFileContents|, which can be either a
full net-internals dump, or a NetLog dump only.  Returns a string
containing a log of the load.
173737
function loadLogFile(logFileContents, fileName) {
    // Try and parse the log dump as a single JSON string.  If this succeeds,
    // it's most likely a full log dump.  Otherwise, it may be a dump created by
    // --log-net-log.
    var parsedDump = null;
    var errorString = '';
    try {
      parsedDump = JSON.parse(logFileContents);
    } catch (error) {
      try {
        // We may have a --log-net-log=blah log dump.  If so, remove the comma
        // after the final good entry, and add the necessary close brackets.
        var end = Math.max(
            logFileContents.lastIndexOf(',\n'),
            logFileContents.lastIndexOf(',\r'));
        if (end != -1) {
          parsedDump = JSON.parse(logFileContents.substring(0, end) + ']}');
          errorString += 'Log file truncated.  Events may be missing.\n';
        }
      } catch (error2) {
      }
    }

    if (!parsedDump)
      return 'Unable to parse log dump as JSON file.';
    return errorString + loadLogDump(parsedDump, fileName);
  }
647872
private static DumpContentType guessDumpContentType(String fileName) {
		String lcDumpName = fileName.toLowerCase();
		if (lcDumpName.contains(".json.gz")) {
			return DumpContentType.JSON;
		} else if (lcDumpName.contains(".json.bz2")) {
			return DumpContentType.JSON;
		} else if (lcDumpName.contains(".sql.gz")) {
			return DumpContentType.SITES;
		} else if (lcDumpName.contains(".xml.bz2")) {
			if (lcDumpName.contains("daily")) {
				return DumpContentType.DAILY;
			} else if (lcDumpName.contains("current")) {
				return DumpContentType.CURRENT;
			} else {
				return DumpContentType.FULL;
			}
		} else {
			logger.warn("Could not guess type of the dump file \"" + fileName
					+ "\". Defaulting to json.gz.");
			return DumpContentType.JSON;
		}
	}
1114
def string_to_level(log_level):
  
  if (log_level.strip().upper() == "DEBUG"):
    return logging.DEBUG
  if (log_level.strip().upper() == "INFO"):
    return logging.INFO
  if (log_level.strip().upper() == "WARNING"):
    return logging.WARNING
  if (log_level.strip().upper() == "ERROR"):
    return logging.ERROR
458937
private String readBlobAsString(Blob logBlob) throws SQLException {
    if (logBlob == null) {
      return StringUtils.EMPTY;
    }

    byte[] ba = logBlob.getBytes(1L, (int) (logBlob.length()));

    if (ba == null) {
      return StringUtils.EMPTY;
    }
    String baString = Base64.encodeBase64String(ba);
    return baString;
  }
1076888
def grep_log(self, expr, filename='system.log', from_mark=None):
        
        matchings = []
        pattern = re.compile(expr)
        with open(os.path.join(self.get_path(), 'logs', filename)) as f:
            if from_mark:
                f.seek(from_mark)
            for line in f:
                m = pattern.search(line)
                if m:
                    matchings.append((line, m))
        return matchings
171994
def get_logfile(logger=None):
    
    logger = logger or logging.getLogger()
    handlers = [i for i in logger.handlers if isinstance(i, logging.FileHandler)]
    return handlers[0].baseFilename if handlers else None
462594
private String getContent(TreeLogger logger, String path, String src)
      throws UnableToCompleteException {
    HttpURLConnection connection = null;
    InputStream in = null;
    try {
      if (!src.matches("(?i)https?://.*")) {
        String file = path + "/" + src;
        in = this.getClass().getClassLoader().getResourceAsStream(file);
        if (in == null) {
          // If we didn't find the resource relative to the package, assume it is absolute.
          file = src;
          in = this.getClass().getClassLoader().getResourceAsStream(file); 
        }
        if (in != null) {
          logger.log(TreeLogger.INFO, getClass().getSimpleName()
              + " - importing external javascript: " + file);
        } else {
          logger.log(TreeLogger.ERROR, "Unable to read javascript file: " + file);
        }
      } else {
        logger.log(TreeLogger.INFO, getClass().getSimpleName()
            + " - downloading external javascript: " + src);
        URL url = new URL(src);
        connection = (HttpURLConnection) url.openConnection();
        connection.setRequestProperty("Accept-Encoding", "gzip, deflate");
        connection.setRequestProperty("Host", url.getHost());
        connection.setConnectTimeout(3000);
        connection.setReadTimeout(3000);

        int status = connection.getResponseCode();
        if (status != HttpURLConnection.HTTP_OK) {
          logger.log(TreeLogger.ERROR, "Server Error: " + status + " "
              + connection.getResponseMessage());
          throw new UnableToCompleteException();
        }

        String encoding = connection.getContentEncoding();
        in = connection.getInputStream();
        if ("gzip".equalsIgnoreCase(encoding)) {
          in = new GZIPInputStream(in);
        } else if ("deflate".equalsIgnoreCase(encoding)) {
          in = new InflaterInputStream(in);
        }
      }

      return inputStreamToString(in);
    } catch (IOException e) {
      logger.log(TreeLogger.ERROR, "Error: " + e.getMessage());
      throw new UnableToCompleteException();
    } finally {
      if (connection != null) {
        connection.disconnect();
      }
    }
  }
758563
private java.io.DataInputStream readNextLogRecord()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this,
                        cclass,
                        "readNextLogRecord",
                        new Object[] { new Long(sectorValidatedInputStream.currentPage),
                                      new Integer(sectorValidatedInputStream.currentByte) });

        byte[] logRecordBytes = null;
        short partLength = 0;
        byte partType = FileLogOutput.PART_First;
        byte multiPartID = 0;
        java.io.DataInputStream logRecordDataInputStream = null;

        // Keep reading until we have assembled a complete LogRecord.
        while (logRecordDataInputStream == null) {
            try {
                // Read the part header.
                partType = dataInputStream.readByte();
                switch (partType) {
                    case FileLogOutput.PART_Padding:
                        // Padding, do nothing.
                        break;

                    case FileLogOutput.PART_First:
                    case FileLogOutput.PART_Middle:
                    case FileLogOutput.PART_Last:
                        multiPartID = dataInputStream.readByte();
                        partLength = dataInputStream.readShort();

                        // Now get the logRecord itself.
                        // TODO We could avoid doing this if the logRecord is single part as it is in fact just the next bytes
                        //      in the datastream.
                        logRecordBytes = new byte[partLength];
                        // There is a bug in JVM 1.4.2 such that dataInput.readFully(byte[],int,int)
                        // returns a partial buffer rather than throwing EOFExcepton. 
                        // dataInputStream.readFully(logRecordBytes);
                        // Anyhow we would rather not block if the file has data missing at the end.
                        int bytesRead = dataInputStream.read(logRecordBytes);
                        if (bytesRead != partLength) {
                            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                                trace.exit(this, cclass
                                           , "readNextLogRecord"
                                           , new Object[] { "LogFileExhausted_1", new Integer(bytesRead), new Short(partLength) }
                                                );
                            throw new LogFileExhaustedException(this, new java.io.EOFException());
                        } // if ( bytesRead != partLength).

                        if (multiPartID == 0) {
                            // partType will be PART_Last, this is the only part.
                            java.io.ByteArrayInputStream byteArrayInputStream = new java.io.ByteArrayInputStream(logRecordBytes);
                            logRecordDataInputStream = new java.io.DataInputStream(byteArrayInputStream);

                        } else if (partType == FileLogOutput.PART_Last) {
                            if (multiPartLogRecords[multiPartID] != null) {
                                multiPartLogRecords[multiPartID].add(logRecordBytes);
                                MultiByteArrayInputStream inputStream = new MultiByteArrayInputStream(multiPartLogRecords[multiPartID]);
                                logRecordDataInputStream = new java.io.DataInputStream(inputStream);
                                multiPartLogRecords[multiPartID] = null;
                            } // if (multiPartLogRecords[multiPartID] != null).

                        } else if (partType == FileLogOutput.PART_First) {
                            multiPartLogRecords[multiPartID] = new java.util.ArrayList();
                            multiPartLogRecords[multiPartID].add(logRecordBytes);
                        } else {
                            if (multiPartLogRecords[multiPartID] != null) {
                                multiPartLogRecords[multiPartID].add(logRecordBytes);
                            }
                        }

                        break;
                    default:
                        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                            trace.exit(this, cclass
                                       , "readNextLogRecord"
                                       , "via InvalidLogPartTypeException partType=" + partType + "(byte)"
                                            );
                        throw new InvalidLogRecordPartTypeException(this
                                                                    , partType);
                        // break;                             // unreachable.
                } // switch (partType).

            } catch (java.io.EOFException exception) {
                // No FFDC Code Needed, condition expected when end of log seen.
                if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                    trace.exit(this, cclass
                               , "readNextLogRecord"
                               , new Object[] { "LogFileExhausted_2", new Short(partLength) }
                                    );
                throw new LogFileExhaustedException(this, exception);

            } catch (java.io.IOException exception) {
                // No FFDC Code Needed.
                ObjectManager.ffdc.processException(cclass, "readNext", exception, "1:348:1.13");

                if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                    trace.exit(this, cclass
                               , "readNextLogRecord"
                               , new Object[] { new Short(partLength), exception }
                                    );
                throw new PermanentIOException(this
                                               , exception);
            } // catch java.io.IOException.

        } // while (logRecordDataInputStream == null).

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       "readNextLogRecord",
                       new Object[] { logRecordDataInputStream });
        return logRecordDataInputStream;
    }
516970
def load_data(cls, relpath):
        
        filepath = os.path.join(cls.data_path, relpath)
        with open(filepath) as fp:
            content = fp.read()

        return content
1144289
def __load_dump(self, message):
        
        dump = message.content
        if self._hook is not None:
            # Call the hook
            try:
                updated_dump = self._hook(message, dump)
                if updated_dump is not None:
                    # Use the new description
                    dump = updated_dump
            except (TypeError, ValueError) as ex:
                self._logger("Invalid description hook: %s", ex)
        return dump
740414
def read_content(self):
        """"""
        buf = StringIO()
        data = self.read_content_chunk()
        while data:
            if buf.tell() + len(data) > self.aggregate.config["maxfilesizedownload"]:
                raise LinkCheckerError(_("File size too large"))
            buf.write(data)
            data = self.read_content_chunk()
        return buf.getvalue()
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)
175360
def file_contents(file_name):
    """"""
    curr_dir = os.path.abspath(os.path.dirname(__file__))
    with open(os.path.join(curr_dir, file_name)) as the_file:
        contents = the_file.read()
    return contents
513450
private String getFullPathForLog(OutputResult or, String targetFilename) {
        if (or.sameDirectory()) {
            return targetFilename;
        } else {
            return or.getGeneratedSource().getFullPath(targetFilename);
        }
    }
224417
def loads(self, string):
    '''  '''
    for line in string.split("\n"):
      if len(line) < 10:
        continue

      try:
        report = ish_report()
        report.loads(line)
        self._reports.append(report)
      except BaseException as exp:
        ''' don't complain TOO much '''
        logging.warning('unable to load report, error: %s' % exp)
846529
def log_internal(args, filetype):
    ''''''
    file_name = get_config_filename(args)
    if filetype == 'stdout':
        file_full_path = os.path.join(NNICTL_HOME_DIR, file_name, 'stdout')
    else:
        file_full_path = os.path.join(NNICTL_HOME_DIR, file_name, 'stderr')
    print(check_output_command(file_full_path, head=args.head, tail=args.tail))
98734
def content(self):
        
        if self._content is None:
            self._content = self.parse_files()
        return self._content