package com.atlassian.stash.internal.logback.pattern;

import ch.qos.logback.classic.pattern.MDCConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import org.apache.commons.lang3.StringUtils;

/**
 * A customization of the standard {@link MDCConverter} that returns a '-' for an empty MDC variable. For non-empty 
 * MDC variables, the behaviour of the standard {@link MDCConverter} applies.
 * 
 * @since 1.2.2
 */
public class DefaultingMDCConverter extends MDCConverter {
    @Override
    public String convert(ILoggingEvent event) {
        return StringUtils.defaultIfEmpty(super.convert(event), "-");
    }
}
