Skip to content

Commit

Permalink
Android: log4net replaced with slf4j
Browse files Browse the repository at this point in the history
  • Loading branch information
nyxiscoo1 committed Jan 26, 2017
1 parent ef7934a commit 1b1c183
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 447 deletions.
7 changes: 3 additions & 4 deletions Source/Core/src/com/shtrih/util/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
*
* @author V.Kravtsov
*/

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.logging.SimpleFormatter;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.Format;

public class Logger {

Expand Down
2 changes: 1 addition & 1 deletion Source/android/FptrServiceAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ repositories {
dependencies {
compile 'd2xx:d2xx:1.0',
'jpos:jpos113:1.13',
'log4j:log4j:1.2.16',
'org.slf4j:slf4j-api:1.7.21',
'xerces4android:xerces4android:1.0',
'zxing:zxing:3.2.2'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@
*/
package com.shtrih.fiscalprinter.port;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
import java.util.Vector;

import org.apache.log4j.Logger;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;

import com.shtrih.util.CompositeLogger;
import com.shtrih.util.Localizer;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
import java.util.Vector;

public class BluetoothPort implements PrinterPort {
private static final UUID MY_UUID = UUID
.fromString("00001101-0000-1000-8000-00805F9B34FB");
Expand All @@ -34,7 +33,7 @@ public class BluetoothPort implements PrinterPort {
private int openTimeout = 10000;
private String portName = "";
private BluetoothSocket socket = null;
static Logger logger = Logger.getLogger(BluetoothPort.class);
private static CompositeLogger logger = CompositeLogger.getLogger(BluetoothPort.class);

/**
* Creates a new instance of BluetoothPort
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package com.shtrih.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
*
* @author V.Kravtsov
*/

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

public class CompositeLogger {

private final Logger log4JLogger;

private CompositeLogger(String className) {
log4JLogger = LogManager.getLogger(className);
log4JLogger = LoggerFactory.getLogger(className);
}

public static synchronized CompositeLogger getLogger(java.lang.Class c) {
Expand All @@ -29,15 +29,15 @@ public void setEnabled(boolean value) {
}

public synchronized void fatal(String text, Throwable e) {
log4JLogger.fatal(text, e);
log4JLogger.error(text, e);
}

public synchronized void error(String text, Throwable e) {
log4JLogger.error(text, e);
}

public synchronized void error(Throwable e) {
log4JLogger.error(e);
log4JLogger.error("Error", e);
}

public synchronized void error(String text) {
Expand Down
1 change: 1 addition & 0 deletions Source/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def getVersionName2() {
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
Expand Down
14 changes: 14 additions & 0 deletions Source/android/tinyJavaPosTester/assets/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<configuration>
<appender name="logcat" class="ch.qos.logback.classic.android.LogcatAppender">
<tagEncoder>
<pattern>%logger{12}</pattern>
</tagEncoder>
<encoder>
<pattern>[%thread] %msg</pattern>
</encoder>
</appender>

<root level="DEBUG">
<appender-ref ref="logcat" />
</root>
</configuration>
14 changes: 14 additions & 0 deletions Source/android/tinyJavaPosTester/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

signingConfigs {
release {
storeFile file("${projectDir}/tinyJavaPOSTester-release-key.keystore")
Expand All @@ -22,6 +23,7 @@ android {
keyPassword "123456"
}
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -33,6 +35,7 @@ android {
}
}
}

productFlavors {
}

Expand All @@ -52,9 +55,14 @@ android {
}
}
}

lintOptions {
abortOnError false
}
}

repositories {
jcenter()

flatDir {
dirs = ['../lib']
Expand All @@ -66,6 +74,12 @@ dependencies {
compile project(':FptrServiceAndroid')
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'com.github.tony19:logback-android-core:1.1.1-6'
compile('com.github.tony19:logback-android-classic:1.1.1-6') {
// workaround issue #73
exclude group: 'com.google.android', module: 'android'
}
}

task dist(type: Copy) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ConfigureLog4J.configure(getApplicationContext());

printer = new ShtrihFiscalPrinter(new FiscalPrinter());
}

Expand Down

This file was deleted.

Loading

0 comments on commit 1b1c183

Please sign in to comment.