All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.applitools.eyes.MultiLogHandler Maven / Gradle / Ivy

There is a newer version: 5.66.0
Show newest version
package com.applitools.eyes;

import com.applitools.eyes.logging.ClientEvent;
import com.applitools.eyes.logging.TraceLevel;

import java.util.*;

public class MultiLogHandler extends LogHandler {
    final Set logHandlers = Collections.synchronizedSet(new HashSet());

    public MultiLogHandler(LogHandler... logHandlers) {
        super(TraceLevel.Debug);
        if (logHandlers == null || logHandlers.length == 0) {
            return;
        }

        this.logHandlers.addAll(Arrays.asList(logHandlers));
    }

    public void addLogHandler(LogHandler logHandler) {
        logHandlers.add(logHandler);
    }

    public void clear() {
        logHandlers.clear();
    }

    @Override
    public void open() {
        synchronized (logHandlers) {
            for (LogHandler logHandler : logHandlers) {
                logHandler.open();
            }
        }
    }

    @Override
    public void onMessageInner(ClientEvent event) {
        synchronized (logHandlers) {
            for (LogHandler logHandler : logHandlers) {
                logHandler.onMessage(event);
            }
        }
    }

    @Override
    public void close() {
        synchronized (logHandlers) {
            for (LogHandler logHandler : logHandlers) {
                logHandler.close();
            }
        }
    }

    @Override
    public boolean isOpen() {
        return true;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy