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

com.undefinedlabs.scope.events.log.LogEvent Maven / Gradle / Ivy

package com.undefinedlabs.scope.events.log;

import com.undefinedlabs.scope.utils.sourcecode.SourceCodeFrame;

public class LogEvent {

  private final String loggerName;
  private final String loggerModule;
  private final String message;
  private final String logLevel;
  private final String logMarker;
  private final String source;

  private LogEvent(final Builder builder) {
    this.loggerName = builder.loggerName;
    this.loggerModule = builder.loggerModule;
    this.message = builder.message;
    this.logLevel = builder.logLevel;
    this.logMarker = builder.logMarker;
    this.source = builder.source;
  }

  public String getLoggerName() {
    return loggerName;
  }

  public String getLoggerModule() {
    return loggerModule;
  }

  public String getMessage() {
    return message;
  }

  public String getLogLevel() {
    return logLevel;
  }

  public String getLogMarker() {
    return logMarker;
  }

  public String getSource() {
    return source;
  }

  public static Builder newBuilder() {
    return new Builder();
  }

  public static class Builder {
    private String loggerName;
    private String loggerModule;
    private String message;
    private String logLevel;
    private String logMarker;
    private String source;

    public Builder withLoggerName(final String loggerName) {
      this.loggerName = loggerName;
      return this;
    }

    public Builder withLoggerModule(final String loggerModule) {
      this.loggerModule = loggerModule;
      return this;
    }

    public Builder withMessage(final String message) {
      this.message = message;
      return this;
    }

    public Builder withLogLevel(final LogLevel logLevel) {
      if (logLevel == null) {
        this.logLevel = LogLevel.NOTSET.name();
        return this;
      }

      this.logLevel = logLevel.name();
      return this;
    }

    public Builder withLogMarker(final String logMarker) {
      this.logMarker = logMarker;
      return this;
    }

    public Builder withSource(final SourceCodeFrame sourceCodeFrame) {
      this.source = sourceCodeFrame.getLinkPathWithMethodLine();
      return this;
    }

    public LogEvent build() {
      return new LogEvent(this);
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy