Remove clashing error prefix; Use better name for RatufaCoat ROMs.
[SquirrelJME.git] / buildSrc / src / main / java / cc / squirreljme / plugin / util / GradleLoggerOutputStream.java
blob83d286f6846ff3ef59d3c5cb298e5305c7ec424d
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc.squirreljme.plugin.util;
12 import java.io.ByteArrayOutputStream;
13 import java.io.IOException;
14 import java.io.OutputStream;
15 import org.gradle.api.logging.LogLevel;
16 import org.gradle.api.logging.Logger;
18 /**
19 * Outputs whatever text to Gradle's Logger interface
21 * @since 2022/07/01
23 public final class GradleLoggerOutputStream
24 extends LinePushOutputStream
26 /** The log level to output as. */
27 private final LogLevel _logLevel;
29 /** The logger to output to. */
30 private final Logger _logger;
32 /** The test ID. */
33 private final int _testId;
35 /** The test total. */
36 private final int _testTotal;
38 /**
39 * Outputs to the given logger.
41 * @param __logger The logger to output to.
42 * @param __logLevel The log level to output under.
43 * @param __testId The test ID, is optional.
44 * @param __testTotal The total number of tests.
45 * @throws NullPointerException On null arguments.
46 * @since 2022/07/01
48 public GradleLoggerOutputStream(Logger __logger, LogLevel __logLevel,
49 int __testId, int __testTotal)
50 throws NullPointerException
52 if (__logger == null || __logLevel == null)
53 throw new NullPointerException("NARG");
55 this._logger = __logger;
56 this._logLevel = __logLevel;
57 this._testId = __testId;
58 this._testTotal = __testTotal;
61 /**
62 * {@inheritDoc}
63 * @since 2022/09/11
65 @Override
66 protected void push(String __string)
68 int testId = this._testId;
69 int testTotal = this._testTotal;
71 // Which output string do we want?
72 String message;
73 if (testId < 0 || testTotal < 0)
74 message = __string;
75 else
76 message = String.format("[%d/%d]: %s", testId, testTotal,
77 __string);
79 // Output to the logger before it goes away
80 this._logger.log(this._logLevel, message);