package org.semagrow.art;

import org.slf4j.MDC;

import java.util.UUID;

public final class LogUtils {

    public static void setMDCifNull() {
        if (MDC.get("uuid") == null) {
            setMDC();
        }
    }

    public static void setMDC() {
        MDC.put("nestingLevel", "1");
        MDC.put("uuid", UUID.randomUUID().toString());
    }

    public static boolean hasKobeQueryDesc(String query) {
        String keyword = "#kobeQueryDesc ";
        return query.startsWith(keyword);
    }

    public static String getKobeQueryDesc(String query) {
        String keyword = "#kobeQueryDesc ";
        assert hasKobeQueryDesc(query);
        int i = keyword.length() - 1;
        int j = query.indexOf('\n') - 1;
        return query.substring(i,j);
    }
}

@@ -676,20 +676,16 @@
 length()
- - 1
 ;%0A      
@@ -717,12 +717,8 @@
 %5Cn')
- - 1
 ;%0A  

fix substring()