Package com.log4jviewer.domain

Source Code of com.log4jviewer.domain.FileLogEvent

package com.log4jviewer.domain;

import com.log4jviewer.logfile.LogRecord;
import com.log4jviewer.logfile.fields.LogLevelName;

/**
* The wrapper class for text file logs. Provides information about log fields.
*
* @author <a href="mailto:rd.ryly@gmail.com">Ruslan Diachenko</a>
*/
public class FileLogEvent implements LogEvent {

    private LogRecord log;

    public FileLogEvent(final LogRecord log) {
        this.log = log;
    }

    @Override
    public String getCategoryName() {
        return StringUtility.emptyStringIfNull(log.getCategoryName());
    }

    @Override
    public String getClassName() {
        return StringUtility.emptyStringIfNull(log.getClassName());
    }

    @Override
    public String getDate() {
        return StringUtility.emptyStringIfNull(log.getDate());
    }

    @Override
    public String getFileName() {
        return StringUtility.emptyStringIfNull(log.getFileName());
    }

    @Override
    public String getLineNumber() {
        String lineInfo = "";
        int lineNumber = log.getLineNumber();

        if (lineNumber > 0) {
            lineInfo = Integer.toString(lineNumber);
        }
        return lineInfo;
    }

    @Override
    public String getMdc() {
        return StringUtility.emptyStringIfNull(log.getMdc());
    }

    @Override
    public String getMessage() {
        return StringUtility.emptyStringIfNull(log.getMessage());
    }

    @Override
    public String getMethodName() {
        return StringUtility.emptyStringIfNull(log.getMethodName());
    }

    @Override
    public String getNdc() {
        return StringUtility.emptyStringIfNull(log.getNdc());
    }

    @Override
    public String getLevel() {
        String levelInfo = "";
        LogLevelName level = log.getLevel();

        if (level != null) {
            levelInfo = level.name();
        }
        return levelInfo;
    }

    @Override
    public String getThreadName() {
        return StringUtility.emptyStringIfNull(log.getThreadName());
    }

    @Override
    public String getThrowableInfo() {
        return "";
    }
}
TOP

Related Classes of com.log4jviewer.domain.FileLogEvent

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.