diff --git a/src/index.ts b/src/index.ts index 5c8c646..e6360ea 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ import PublisherTarget from "./publishing/publisher-target"; import { getInputAsObject, mapNumberInput } from "./utils/input-utils"; import { getDefaultLogger } from "./utils/logger-utils"; import { retry } from "./utils/function-utils"; +import LoggingStopwatch from "./utils/logging-stopwatch"; async function main() { const commonOptions = getInputAsObject(); @@ -25,8 +26,7 @@ async function main() { const retryDelay = mapNumberInput(options.retryDelay); const publisher = publisherFactory.create(target, logger); - logger.info(`Publishing assets to ${targetName}...`); - const start = new Date(); + const stopwatch = LoggingStopwatch.startNew(logger, `Publishing assets to ${targetName}...`, ms => `Successfully published assets to ${targetName} (in ${ms} ms)`); await retry({ func: () => publisher.publish(files, options), @@ -38,8 +38,7 @@ async function main() { } }); - const end = new Date(); - logger.info(`Successfully published assets to ${targetName} (in ${end.getTime() - start.getTime()} ms)`); + stopwatch.stop(); publishedTo.push(targetName); } diff --git a/src/publishing/modrinth/modrinth-publisher.ts b/src/publishing/modrinth/modrinth-publisher.ts index 54098c6..6cf9632 100644 --- a/src/publishing/modrinth/modrinth-publisher.ts +++ b/src/publishing/modrinth/modrinth-publisher.ts @@ -5,6 +5,7 @@ import PublisherTarget from "../publisher-target"; import Dependency from "../../metadata/dependency"; import DependencyKind from "../../metadata/dependency-kind"; import { mapBooleanInput, mapEnumInput } from "../../utils/input-utils"; +import LoggingStopwatch from "../../utils/logging-stopwatch"; enum UnfeatureMode { None = 0, @@ -68,9 +69,8 @@ export default class ModrinthPublisher extends ModPublisher { } private async unfeatureOlderVersions(id: string, token: string, unfeatureMode: UnfeatureMode, loaders: string[], gameVersions: string[]): Promise { - this.logger.info("Unfeaturing older Modrinth versions..."); - const start = new Date(); - const unfeaturedVersions = []; + const unfeaturedVersions = new Array(); + const stopwatch = LoggingStopwatch.startNew(this.logger, "Unfeaturing older Modrinth versions...", ms => `Successfully unfeatured: ${unfeaturedVersions.join(", ")} (in ${ms} ms)`); const versionSubset = hasFlag(unfeatureMode, UnfeatureMode.VersionSubset); const loaderSubset = hasFlag(unfeatureMode, UnfeatureMode.LoaderSubset); @@ -92,8 +92,7 @@ export default class ModrinthPublisher extends ModPublisher { } if (unfeaturedVersions.length) { - const end = new Date(); - this.logger.info(`Successfully unfeatured versions ${unfeaturedVersions.join(", ")} (in ${end.getTime() - start.getTime()} ms)`); + stopwatch.stop(); } else { this.logger.info("No versions to unfeature were found"); }