Java Log Exception logException(int type, String RID, String subRID, String propIndication, String error)

Here you can find the source of logException(int type, String RID, String subRID, String propIndication, String error)

Description

log Exception

License

Apache License

Declaration

public static void logException(int type, String RID, String subRID, String propIndication, String error) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;

import java.util.Map;

public class Main {
    public static final int ET_OUTLINE = 4;
    public static final Map<Integer, String> logNames = new HashMap<Integer, String>();
    public static final Map<Integer, FileWriter> writers = new HashMap<Integer, FileWriter>();

    public static void logException(int type, String RID, String subRID, String propIndication, String error) {
        //System.out.println(error);
        FileWriter f = getFileWriter(type);
        try {/*from  www. java2 s.com*/
            f.write("- [ ] [" + subRID + "](" + getUri(type, RID, subRID) + ") ");
            f.write("on property `" + propIndication + "`: " + error + "\n");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void logException(int type, String RID, String subRID, String rawError) {
        //System.out.println(error);
        FileWriter f = getFileWriter(type);
        try {
            f.write("- [ ] [" + subRID + "](" + getUri(type, RID, subRID) + ") " + rawError + "\n");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static FileWriter getFileWriter(int type) {
        FileWriter res = writers.get(type);
        if (res == null) {
            String fileName = logNames.get(type);
            try {
                res = new FileWriter(fileName);
            } catch (IOException e) {
                e.printStackTrace();
            }
            writers.put(type, res);
        }
        return res;
    }

    public static String getUri(int type, String RID, String subRID) {
        if (type == ET_OUTLINE) {
            return "https://www.tbrc.org/#library_work_ViewByOutline-" + subRID + "|" + RID;
        }
        return "https://www.tbrc.org/#!rid=" + RID;
    }
}

Related

  1. logError(Exception e)
  2. logError(String s, Throwable e)
  3. logException(Exception e, Logger logger)
  4. LogException(Exception ex)
  5. logException(final Throwable exception)
  6. logException(Logger logger, Level logLevel, Exception e)
  7. logException(Logger logger, String message, Throwable t)
  8. logException(Logger logger, Throwable t)
  9. LogException(String description, Throwable e)