Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to SLF4J #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions apps/sparkpost-documentor-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
<groupId>com.sparkpost</groupId>
<artifactId>sparkpost-lib</artifactId>
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down
4 changes: 4 additions & 0 deletions apps/sparkpost-javamail-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<groupId>com.sparkpost</groupId>
<artifactId>sparkpost-lib</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostException;
import com.sparkpost.model.AddressAttributes;
Expand All @@ -41,8 +38,6 @@
public class App extends SparkPostBaseApp {

public static void main(String[] args) throws Exception {
Logger.getRootLogger().setLevel(Level.DEBUG);

App app = new App();
app.runApp();
}
Expand Down
9 changes: 6 additions & 3 deletions apps/sparkpost-samples-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
<groupId>com.sparkpost</groupId>
<artifactId>sparkpost-lib</artifactId>
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import java.io.IOException;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostAccessForbiddenException;
Expand All @@ -19,13 +19,11 @@
*/
public class BadApiKeyErrorSample extends SparkPostBaseApp {

static final Logger logger = Logger.getLogger(BadApiKeyErrorSample.class);
static final Logger logger = LoggerFactory.getLogger(BadApiKeyErrorSample.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);

BadApiKeyErrorSample sample = new BadApiKeyErrorSample();
sample.runApp();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import java.io.IOException;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostErrorServerResponseException;
Expand All @@ -17,13 +17,11 @@

public class ForceTransportError extends SparkPostBaseApp {

static final Logger logger = Logger.getLogger(ForceTransportError.class);
static final Logger logger = LoggerFactory.getLogger(ForceTransportError.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);

ForceTransportError app = new ForceTransportError();
app.runApp();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.util.List;
import java.util.Map;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostErrorServerResponseException;
Expand All @@ -25,13 +25,11 @@

public class SendEmailErrorSample extends SparkPostBaseApp {

static final Logger logger = Logger.getLogger(SendEmailErrorSample.class);
static final Logger logger = LoggerFactory.getLogger(SendEmailErrorSample.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);

SendEmailErrorSample sample = new SendEmailErrorSample();
sample.runApp();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.util.List;
import java.util.Map;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostErrorServerResponseException;
Expand All @@ -25,13 +25,11 @@

public class SendInvalidFromAddress extends SparkPostBaseApp {

static final Logger logger = Logger.getLogger(SendInvalidFromAddress.class);
static final Logger logger = LoggerFactory.getLogger(SendInvalidFromAddress.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);

SendInvalidFromAddress sample = new SendInvalidFromAddress();
sample.runApp();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostException;
Expand All @@ -33,13 +33,11 @@
*/
public class CreateRecipientListSample extends SparkPostBaseApp {

static final Logger logger = Logger.getLogger(CreateTemplateSimple.class);
static final Logger logger = LoggerFactory.getLogger(CreateTemplateSimple.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);

CreateRecipientListSample app = new CreateRecipientListSample();
app.runApp();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import java.io.IOException;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostException;
Expand All @@ -22,13 +22,11 @@
*/
public class CreateTemplateFromFile extends SparkPostBaseApp {

private static final Logger logger = Logger.getLogger(CreateTemplateSimple.class);
private static final Logger logger = LoggerFactory.getLogger(CreateTemplateSimple.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);

CreateTemplateFromFile sample = new CreateTemplateFromFile();
sample.runApp();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import java.io.IOException;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostException;
Expand All @@ -22,13 +22,11 @@
*/
public class CreateTemplateFromFile2 extends SparkPostBaseApp {

private static final Logger logger = Logger.getLogger(CreateTemplateSimple.class);
private static final Logger logger = LoggerFactory.getLogger(CreateTemplateSimple.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);

CreateTemplateFromFile2 sample = new CreateTemplateFromFile2();
sample.runApp();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

package com.sparkpost.samples;

import java.io.IOException;
import java.util.List;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostException;
Expand All @@ -19,54 +20,50 @@

public class CreateTemplateSimple extends SparkPostBaseApp {

private static final Logger logger = Logger.getLogger(CreateTemplateSimple.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);

CreateTemplateSimple sample = new CreateTemplateSimple();
sample.runApp();

}

private void runApp() throws SparkPostException, IOException {
client = this.newConfiguredClient();
createTemplate();
}

/**
* Demonstrates how to store an email template in SparkPost
*
* @throws SparkPostException
*/
public void createTemplate() throws SparkPostException {
if (logger.isDebugEnabled()) {
logger.debug("createTemplate()");
}
TemplateAttributes tpl = new TemplateAttributes();

tpl.setName(SAMPLE_TEMPLATE_NAME);
tpl.setContent(new TemplateContentAttributes());
tpl.getContent().setFrom(new AddressAttributes(client.getFromEmail(), "me", null));
tpl.getContent().setHtml("Hello!");
tpl.getContent().setSubject("Template Test");
IRestConnection connection = new RestConnection(client, getEndPoint());
Response response = ResourceTemplates.create(connection, tpl);

if (logger.isDebugEnabled()) {
logger.debug("Create Template Response: " + response);
}
}

public void sendEmail(String templateName, List<String> recipients) {
if (logger.isDebugEnabled()) {
logger.debug("sendEmail(...)");
}

}



private static final Logger logger = LoggerFactory.getLogger(CreateTemplateSimple.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
CreateTemplateSimple sample = new CreateTemplateSimple();
sample.runApp();

}

private void runApp() throws SparkPostException, IOException {
this.client = this.newConfiguredClient();
createTemplate();
}

/**
* Demonstrates how to store an email template in SparkPost
*
* @throws SparkPostException
*/
public void createTemplate() throws SparkPostException {
if (logger.isDebugEnabled()) {
logger.debug("createTemplate()");
}
TemplateAttributes tpl = new TemplateAttributes();

tpl.setName(SAMPLE_TEMPLATE_NAME);
tpl.setContent(new TemplateContentAttributes());
tpl.getContent().setFrom(new AddressAttributes(this.client.getFromEmail(), "me", null));
tpl.getContent().setHtml("Hello!");
tpl.getContent().setSubject("Template Test");
IRestConnection connection = new RestConnection(this.client, getEndPoint());
Response response = ResourceTemplates.create(connection, tpl);

if (logger.isDebugEnabled()) {
logger.debug("Create Template Response: " + response);
}
}

public void sendEmail(String templateName, List<String> recipients) {
if (logger.isDebugEnabled()) {
logger.debug("sendEmail(...)");
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.io.IOException;
import java.util.List;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostException;
Expand All @@ -22,13 +22,11 @@
*/
public class DeleteSampleTemplates extends SparkPostBaseApp {

static final Logger logger = Logger.getLogger(DeleteSampleTemplates.class);
static final Logger logger = LoggerFactory.getLogger(DeleteSampleTemplates.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);

DeleteSampleTemplates sample = new DeleteSampleTemplates();
sample.runApp();
}
Expand Down
Loading