Package com.slicklog.remotelogger

Source Code of com.slicklog.remotelogger.SlickLogRemoteLoggerBuilder

/*
* Copyright (c) 2013. SlickLog.
*/
package com.slicklog.remotelogger;

import com.slicklog.remotelogger.exceptions.SlickLogRemoteLoggerException;
import com.slicklog.remotelogger.model.SlickLog;
import java.io.UnsupportedEncodingException;

/**
*
* @author Torindo Nesci
*/
public class SlickLogRemoteLoggerBuilder {

  private String mEndpoint;
  private String mApiKey;
  private String mLogGroupName;
  private String mLogName;
  private boolean mDebug = false;
  private boolean mSpawnNewThreads = false;

  public String getEndpoint() {
    return mEndpoint;
  }

  public String getApiKey() {
    return mApiKey;
  }

  public String getLogGroupName() {
    return mLogGroupName;
  }

  public String getLogName() {
    return mLogName;
  }

  public boolean getDebug() {
    return mDebug;
  }
 
  public boolean getSpawnNewThreads() {
    return mSpawnNewThreads;
  }
 
  public SlickLogRemoteLoggerBuilder withEndpoint(String endpoint) {
    mEndpoint = endpoint;
    return this;
  }

  public SlickLogRemoteLoggerBuilder withApiKey(String apiKey) {
    mApiKey = apiKey;
    return this;
  }

  public SlickLogRemoteLoggerBuilder withLogGroupName(String logGroupName) {
    mLogGroupName = logGroupName;
    return this;
  }

  public SlickLogRemoteLoggerBuilder withLogName(String logName) {
    mLogName = logName;
    return this;
  }
 
  public SlickLogRemoteLoggerBuilder withDebug(boolean debug) {
    mDebug = debug;
    return this;
  }
 
  public SlickLogRemoteLoggerBuilder withSpawnNewThreads(boolean spawnNewThreds) {
    mSpawnNewThreads = spawnNewThreds;
    return this;
  }
 
  private SlickLogRemoteLogger build(SlickLog slicklog, InternalLogger logger) {
    try {
      SlickLogConnectionBuilder connBuilder = new SlickLogConnectionBuilder(slicklog, logger);
      return new SlickLogRemoteLogger(connBuilder, logger, mSpawnNewThreads);
    } catch (UnsupportedEncodingException ex) {
      throw  new SlickLogRemoteLoggerException(ex);
    }
  }
 
  public SlickLogRemoteLogger buildAndInit() {
    InternalLogger logger = new DefaultInternalLogger(mDebug);
    SlickLog slicklog = new SlickLog();
    slicklog.setApiKey(mApiKey);
    slicklog.setLogGroupName(mLogGroupName);
    slicklog.setLogName(mLogName);
    slicklog.setEndpoint(mEndpoint);

    SlickLogRemoteLogger remoteLogger = build(slicklog, logger);
    remoteLogger.init();
    return remoteLogger;
  }

}
TOP

Related Classes of com.slicklog.remotelogger.SlickLogRemoteLoggerBuilder

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.