Merge branch 'stable-2.15'

* stable-2.15:
  Improve hook debug documentation
  Increase timeout and non-zero exit logs to error level

Change-Id: I35ce660c3bd3d062e488d1bef1a3f4a5df9e8f52
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookTask.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookTask.java
index 7a7189a..7fbf1a7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookTask.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookTask.java
@@ -113,7 +113,7 @@
     } catch (InterruptedException iex) {
       // InterruptedException - timeout or cancel
       args.metrics.timeout(name);
-      log.warn("hook[{}] timed out: {}", name, iex.getMessage());
+      log.error("hook[{}] timed out: {}", name, iex.getMessage());
     } catch (Throwable err) {
       args.metrics.error(name);
       log.error("Error running hook {}", hook.toAbsolutePath(), err);
@@ -122,7 +122,7 @@
     if (result != null) {
       int exitValue = result.getExitValue();
       if (exitValue != 0) {
-        log.warn("hook[{}] exited with error status: {}", name, exitValue);
+        log.error("hook[{}] exited with error status: {}", name, exitValue);
       }
 
       if (log.isDebugEnabled()) {
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index 1023f69..778f4cc 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -94,13 +94,17 @@
 Debugging Hooks
 ---------------
 
-After execution of a hook, its exit code and any output are logged at
-debug level. To make this visible in Gerrit's log file, debug logging
-must be enabled for `com.googlesource.gerrit.plugins.hooks.HookTask`.
+If execution of a hook failed (i.e. it returned a non-zero exit code) the
+exit code is logged at error level. Likewise, if a hook timed out or was
+cancelled, this is logged at error level.
 
-This can be done by editing the `log4j.properties` file (requires a
-Gerrit restart) or by setting the log level at runtime with the ssh
-command:
+Any output (including both stdout and stderr) from the hook is logged at
+debug level.
+
+To make debug logs visible in Gerrit's log file, debug logging must be
+enabled for `com.googlesource.gerrit.plugins.hooks.HookTask`. This can be
+done by editing the `log4j.properties` file (requires a Gerrit restart) or
+by setting the log level at runtime with the ssh command:
 
 ```
   ssh -p 29418 user@gerrit gerrit logging set-level DEBUG com.googlesource.gerrit.plugins.hooks.HookTask