Skip to content

Commit

Permalink
decrease log level for annotation problems (#4083)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladak authored Oct 31, 2022
1 parent 3333c27 commit 8a7aa08
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
*/
package org.opengrok.indexer.history;

Expand Down Expand Up @@ -49,11 +49,14 @@ public class AccuRevAnnotationParser implements Executor.StreamHandler {
*/
private final Annotation annotation;

private final String fileName;

/**
* @param fileName the name of the file being annotated
*/
public AccuRevAnnotationParser(String fileName) {
annotation = new Annotation(fileName);
this.fileName = fileName;
}

/**
Expand Down Expand Up @@ -85,14 +88,14 @@ public void processStream(InputStream input) throws IOException {
String author = matcher.group(2);
annotation.addLine(version, author, true);
} else {
LOGGER.log(Level.SEVERE,
"Did not find annotation in line {0}: [{1}]",
new Object[]{lineno, line});
LOGGER.log(Level.WARNING,
"Did not find annotation in line {0} for ''{1}'': [{2}]",
new Object[]{lineno, this.fileName, line});
}
}
} catch (IOException e) {
LOGGER.log(Level.SEVERE,
"Could not read annotations for " + annotation.getFilename(), e);
LOGGER.log(Level.WARNING,
String.format("Could not read annotations for '%s'", this.fileName), e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
*/
package org.opengrok.indexer.history;

Expand Down Expand Up @@ -49,14 +49,16 @@ public class BazaarAnnotationParser implements Executor.StreamHandler {
/**
* Pattern used to extract author/revision.
*/
private static final Pattern BLAME_PATTERN
= Pattern.compile("^\\W*(\\S+)\\W+(\\S+).*$");
private static final Pattern BLAME_PATTERN = Pattern.compile("^\\W*(\\S+)\\W+(\\S+).*$");

private final String fileName;

/**
* @param fileName the name of the file being annotated
*/
public BazaarAnnotationParser(String fileName) {
annotation = new Annotation(fileName);
this.fileName = fileName;
}

/**
Expand All @@ -82,9 +84,9 @@ public void processStream(InputStream input) throws IOException {
String author = matcher.group(2).trim();
annotation.addLine(rev, author, true);
} else {
LOGGER.log(Level.SEVERE,
"Error: did not find annotation in line {0}: [{1}]",
new Object[]{String.valueOf(lineno), line});
LOGGER.log(Level.WARNING,
"Error: did not find annotation in line {0} for ''{1}'': [{2}]",
new Object[]{String.valueOf(lineno), this.fileName, line});
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
*/
package org.opengrok.indexer.history;

Expand All @@ -43,19 +43,21 @@ public class CVSAnnotationParser implements Executor.StreamHandler {
/**
* Pattern used to extract author/revision from {@code cvs annotate}.
*/
private static final Pattern ANNOTATE_PATTERN
= Pattern.compile("([\\.\\d]+)\\W+\\((\\w+)");
private static final Pattern ANNOTATE_PATTERN = Pattern.compile("([\\.\\d]+)\\W+\\((\\w+)");

/**
* Store annotation created by processStream.
*/
private final Annotation annotation;

private final String fileName;

/**
* @param fileName the name of the file being annotated
*/
public CVSAnnotationParser(String fileName) {
annotation = new Annotation(fileName);
this.fileName = fileName;
}

/**
Expand All @@ -76,8 +78,7 @@ public void processStream(InputStream input) throws IOException {
Matcher matcher = ANNOTATE_PATTERN.matcher(line);
while ((line = in.readLine()) != null) {
// Skip header
if (!hasStarted && (line.length() == 0
|| !Character.isDigit(line.charAt(0)))) {
if (!hasStarted && (line.length() == 0 || !Character.isDigit(line.charAt(0)))) {
continue;
}
hasStarted = true;
Expand All @@ -90,9 +91,9 @@ public void processStream(InputStream input) throws IOException {
String author = matcher.group(2).trim();
annotation.addLine(rev, author, true);
} else {
LOGGER.log(Level.SEVERE,
"Error: did not find annotation in line {0}: [{1}]",
new Object[]{String.valueOf(lineno), line});
LOGGER.log(Level.WARNING,
"Error: did not find annotation in line {0} for ''{1}'': [{2}]",
new Object[]{String.valueOf(lineno), this.fileName, line});
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
*/
package org.opengrok.indexer.history;

Expand Down Expand Up @@ -50,8 +50,7 @@ class MercurialAnnotationParser implements Executor.StreamHandler {
/**
* Pattern used to extract author/revision from {@code hg annotate}.
*/
private static final Pattern ANNOTATION_PATTERN
= Pattern.compile("^\\s*(\\d+):");
private static final Pattern ANNOTATION_PATTERN = Pattern.compile("^\\s*(\\d+):");

MercurialAnnotationParser(File file, HashMap<String, HistoryEntry> revs) {
this.file = file;
Expand All @@ -78,9 +77,9 @@ public void processStream(InputStream input) throws IOException {
}
annotation.addLine(rev, Util.getEmail(author.trim()), true);
} else {
LOGGER.log(Level.SEVERE,
"Error: did not find annotation in line {0}: [{1}]",
new Object[]{lineno, line});
LOGGER.log(Level.WARNING,
"Error: did not find annotation in line {0} for ''{1}'': [{2}]",
new Object[]{lineno, this.file, line});
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2020, Chris Fraire <[email protected]>.
*/
package org.opengrok.indexer.history;
Expand Down Expand Up @@ -101,14 +101,14 @@ public void processStream(InputStream input) throws IOException {
String author = revAuthor.get(revision);
annotation.addLine(revision, author, true);
} else {
LOGGER.log(Level.SEVERE,
"Error: did not find annotation in line {0}: [{1}]",
new Object[]{lineno, line});
LOGGER.log(Level.WARNING,
"Error: did not find annotation in line {0} for ''{1}'': [{2}]",
new Object[]{lineno, this.file, line});
}
}
} catch (IOException e) {
LOGGER.log(Level.SEVERE,
"Error: Could not read annotations for " + annotation.getFilename(), e);
LOGGER.log(Level.WARNING,
String.format("Error: Could not read annotations for '%s'", this.file), e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
*/
package org.opengrok.indexer.history;

Expand Down Expand Up @@ -67,9 +67,9 @@ public void processStream(InputStream input) throws IOException {
String author = matcher.group(2);
annotation.addLine(rev, author, true);
} else {
LOGGER.log(Level.SEVERE,
"Error: did not find annotation in line {0}: [{1}]",
new Object[]{lineno, line});
LOGGER.log(Level.WARNING,
"Error: did not find annotation in line {0} for ''{1}'': [{2}]",
new Object[]{lineno, this.file, line});
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2018, Chris Fraire <[email protected]>.
*/
package org.opengrok.indexer.history;
Expand Down Expand Up @@ -333,9 +333,9 @@ protected Annotation parseAnnotation(Reader input, String fileName)
String author = matcher.group(1);
ret.addLine(rev, author, true);
} else if (hasStarted) {
LOGGER.log(Level.SEVERE,
"Error: did not find annotation in line {0}: [{1}]",
new Object[]{String.valueOf(lineno), line});
LOGGER.log(Level.WARNING,
"Error: did not find annotation in line {0} for ''{1}'': [{2}]",
new Object[]{String.valueOf(lineno), fileName, line});
}
}
return ret;
Expand Down

0 comments on commit 8a7aa08

Please sign in to comment.