/**
 * Copyright © 2012 Joe Littlejohn
 *
 * 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 com.github.joelittlejohn.embedmongo.log;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

import de.flapdoodle.embedmongo.io.IStreamProcessor;

public class FileOutputStreamProcessor implements IStreamProcessor {

    private static OutputStreamWriter stream;

    private synchronized void write(String text) {
        try {

            if (stream == null) {
                stream = new OutputStreamWriter(new FileOutputStream("embedmongo.log"), "utf-8");
            }

            stream.write(text);
            stream.flush();

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void process(String block) {
        write(block);
    }

    @Override
    public void onProcessed() {
        write("\n");
    }
}

/**
 * Copyright © 2012 Joe Littlejohn
 *
 * 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 com.github.joelittlejohn.embedmongo.log;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

import de.flapdoodle.embedmongo.io.IStreamProcessor;

public class FileOutputStreamProcessor implements IStreamProcessor {

    private static OutputStreamWriter stream;

    @Override
    public synchronized void process(String block) {
        try {

            if (stream == null) {
                stream = new OutputStreamWriter(new FileOutputStream("embedmongo.log"), "utf-8");
            }

            stream.write(block);
            stream.flush();

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void onProcessed() {
        process("\n");
    }
}

Remove unnecessary method