/*
 * Copyright 2017, TeamDev Ltd. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package io.spine.tools.gcs;

import com.google.api.client.http.HttpTransport;
import com.google.common.annotations.VisibleForTesting;
import io.spine.tools.gradle.SpinePlugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.slf4j.Logger;

import java.util.logging.Level;

import static io.spine.tools.gradle.TaskName.CLEAN_GCS;
import static org.slf4j.LoggerFactory.getLogger;

/**
 * The plugin for working with Google Cloud Storage via Gradle tasks.
 *
 * @author Dmytro Grankin
 */
public class GcsPlugin extends SpinePlugin {

    @Override
    public void apply(Project project) {
        limitHttpLogging();

        final Task task = project.getTasks()
                                 .create(CLEAN_GCS.getValue(), CleanGcsTask.class);
        log().debug("{} added.", task);
    }

    /**
     * Sets {@link HttpTransport} logging level to {@link Level#WARNING}.
     *
     * <p>The goal of this is to limit excessive logging about
     * {@linkplain com.google.api.client.http.HttpRequest HTTP requests} and
     * {@linkplain com.google.api.client.http.HttpResponse HTTP responses}.
     */
    @VisibleForTesting
    static void limitHttpLogging() {
        final String name = HttpTransport.class.getName();
        final java.util.logging.Logger log = java.util.logging.Logger.getLogger(name);
        log.setLevel(Level.WARNING);
    }

    private static Logger log() {
        return LogSingleton.INSTANCE.value;
    }

    private enum LogSingleton {
        INSTANCE;
        @SuppressWarnings("NonSerializableFieldInSerializableClass")
        private final Logger value = getLogger(GcsPlugin.class);
    }
}

@@ -1248,33 +1248,8 @@
 ask;
-%0Aimport org.slf4j.Logger;
 %0A%0Aim
@@ -1338,57 +1338,8 @@
 GCS;
-%0Aimport static org.slf4j.LoggerFactory.getLogger;
 %0A%0A/*
@@ -2314,283 +2314,7 @@
    %7D
-%0A%0A    private static Logger log() %7B%0A        return LogSingleton.INSTANCE.value;%0A    %7D%0A%0A    private enum LogSingleton %7B%0A        INSTANCE;%0A        @SuppressWarnings(%22NonSerializableFieldInSerializableClass%22)%0A        private final Logger value = getLogger(GcsPlugin.class);%0A    %7D
 %0A%7D%0A

Bump Spine Base -> `0.10.27-SNAPSHOT`