Add a no-op UploadPackLogger and use it by default
This matches the behavior of the hooks in UploadPack. Change-Id: I21277e52ee9452237d87084f06bb140dfa6bf608
This commit is contained in:
parent
cd958ba93c
commit
d6172dc0de
|
@ -217,7 +217,7 @@ public static enum RequestPolicy {
|
||||||
|
|
||||||
private PackWriter.Statistics statistics;
|
private PackWriter.Statistics statistics;
|
||||||
|
|
||||||
private UploadPackLogger logger;
|
private UploadPackLogger logger = UploadPackLogger.NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new pack upload for an open repository.
|
* Create a new pack upload for an open repository.
|
||||||
|
@ -376,6 +376,11 @@ public void setPackConfig(PackConfig pc) {
|
||||||
this.packConfig = pc;
|
this.packConfig = pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return the configured logger. */
|
||||||
|
public UploadPackLogger getLogger() {
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the logger.
|
* Set the logger.
|
||||||
*
|
*
|
||||||
|
@ -1111,7 +1116,7 @@ else if (ref.getName().startsWith(Constants.R_HEADS))
|
||||||
if (sideband)
|
if (sideband)
|
||||||
pckOut.end();
|
pckOut.end();
|
||||||
|
|
||||||
if (logger != null && statistics != null)
|
if (statistics != null)
|
||||||
logger.onPackStatistics(statistics);
|
logger.onPackStatistics(statistics);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,13 @@
|
||||||
* the connection information before invoking UploadPack.
|
* the connection information before invoking UploadPack.
|
||||||
*/
|
*/
|
||||||
public interface UploadPackLogger {
|
public interface UploadPackLogger {
|
||||||
|
/** A simple no-op logger. */
|
||||||
|
public static final UploadPackLogger NULL = new UploadPackLogger() {
|
||||||
|
public void onPackStatistics(PackWriter.Statistics stats) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notice to the logger after a pack has been sent.
|
* Notice to the logger after a pack has been sent.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue