/*
 * Copyright 2009 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gradle;

import org.gradle.api.execution.TaskExecutionGraph;
import org.gradle.api.execution.TaskExecutionGraphListener;
import org.gradle.api.initialization.Settings;
import org.gradle.api.internal.SettingsInternal;
import org.gradle.api.internal.project.ProjectInternal;
import org.gradle.api.invocation.Gradle;
import org.gradle.api.logging.Logger;
import org.gradle.initialization.BuildRequestMetaData;
import org.gradle.internal.logging.text.StyledTextOutputFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * A {@link org.gradle.BuildListener} which logs the build progress.
 */
@Deprecated
public class BuildLogger implements BuildListener, TaskExecutionGraphListener {
    private final Logger logger;
    private final List<BuildListener> resultLoggers = new ArrayList<BuildListener>();

    public BuildLogger(Logger logger, StyledTextOutputFactory textOutputFactory, StartParameter startParameter, BuildRequestMetaData requestMetaData) {
        this.logger = logger;
        resultLoggers.add(new BuildExceptionReporter(textOutputFactory, startParameter, requestMetaData.getClient()));
        resultLoggers.add(new BuildResultLogger(textOutputFactory, requestMetaData.getBuildTimeClock()));
    }

    public void buildStarted(Gradle gradle) {
        StartParameter startParameter = gradle.getStartParameter();
        logger.info("Starting Build");
        logger.debug("Gradle user home: " + startParameter.getGradleUserHomeDir());
        logger.debug("Current dir: " + startParameter.getCurrentDir());
        logger.debug("Settings file: " + startParameter.getSettingsFile());
        logger.debug("Build file: " + startParameter.getBuildFile());
    }

    public void settingsEvaluated(Settings settings) {
        SettingsInternal settingsInternal = (SettingsInternal) settings;
        logger.info(String.format("Settings evaluated using %s.",
                settingsInternal.getSettingsScript().getDisplayName()));
    }

    public void projectsLoaded(Gradle gradle) {
        ProjectInternal projectInternal = (ProjectInternal) gradle.getRootProject();
        logger.info(String.format("Projects loaded. Root project using %s.",
                projectInternal.getBuildScriptSource().getDisplayName()));
        logger.info(String.format("Included projects: %s", projectInternal.getAllprojects()));
    }

    public void projectsEvaluated(Gradle gradle) {
        logger.info("All projects evaluated.");
    }

    public void graphPopulated(TaskExecutionGraph graph) {
        logger.info("Tasks to be executed: {}", graph.getAllTasks());
    }

    public void buildFinished(BuildResult result) {
        for (BuildListener logger : resultLoggers) {
            logger.buildFinished(result);
        }
    }
}
@@ -2042,19 +2042,20 @@
 r home: 
-%22 +
+%7B%7D%22,
  startPa
@@ -2122,19 +2122,20 @@
 nt dir: 
-%22 +
+%7B%7D%22,
  startPa
@@ -2193,27 +2193,28 @@
 tings file: 
-%22 +
+%7B%7D%22,
  startParame
@@ -2275,11 +2275,12 @@
 le: 
-%22 +
+%7B%7D%22,
  sta
@@ -2463,30 +2463,16 @@
 er.info(
-String.format(
 %22Setting
@@ -2485,26 +2485,26 @@
 uated using 
-%25s
+%7B%7D
 .%22,%0A        
@@ -2561,25 +2561,24 @@
 splayName())
-)
 ;%0A    %7D%0A%0A   
@@ -2727,30 +2727,16 @@
 er.info(
-String.format(
 %22Project
@@ -2764,18 +2764,18 @@
 t using 
-%25s
+%7B%7D
 .%22,%0A    
@@ -2842,17 +2842,16 @@
 yName())
-)
 ;%0A      
@@ -2868,22 +2868,8 @@
 nfo(
-String.format(
 %22Inc
@@ -2888,10 +2888,10 @@
 ts: 
-%25s
+%7B%7D
 %22, p
@@ -2922,17 +2922,16 @@
 jects())
-)
 ;%0A    %7D%0A
@@ -3337,8 +3337,9 @@
 %0A    %7D%0A%7D
+%0A

Replace some calls to String.format with SLF4J's {}