Repair logging
This commit is contained in:
@ -9,6 +9,7 @@ import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.MarkerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
@ -104,9 +105,9 @@ public class MainController implements ServletContextAware {
|
||||
}*/
|
||||
|
||||
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ex) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(uuid, e);
|
||||
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
@ -169,7 +170,6 @@ public class MainController implements ServletContextAware {
|
||||
@CookieValue(value = "lng", defaultValue = "1") String language_id
|
||||
) {
|
||||
Properties props = new Properties();
|
||||
String error="":
|
||||
try {
|
||||
String sql="""
|
||||
select
|
||||
@ -194,7 +194,8 @@ public class MainController implements ServletContextAware {
|
||||
}
|
||||
} catch( DataAccessException ex )
|
||||
{
|
||||
logger.info(ex.getMessage());
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||
}
|
||||
|
||||
//In JavaScript code
|
||||
|
||||
@ -2,11 +2,15 @@ package org.ccalm.translation.tools;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.MarkerFactory;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Cache implements AutoCloseable {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(Cache.class);
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Cache.class);
|
||||
private Jedis jedis = null;
|
||||
|
||||
String host = null;
|
||||
@ -23,9 +27,10 @@ public class Cache implements AutoCloseable {
|
||||
try {
|
||||
jedis = new Jedis(host, port);
|
||||
jedis.auth(password);
|
||||
}catch (Exception e)
|
||||
}catch (Exception ex)
|
||||
{
|
||||
logger.error(e);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6,14 +6,17 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.ccalm.translation.models.ErrorResponseModel;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.MarkerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public class CustomException extends Exception {
|
||||
private static final Logger logger = LogManager.getLogger(CustomException.class);
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(CustomException.class);
|
||||
|
||||
private ErrorResponseModel error;
|
||||
@Getter
|
||||
@ -70,8 +73,9 @@ public class CustomException extends Exception {
|
||||
json.put("error_message", this.getErrorMessages());
|
||||
json.put("error_setting", this.getErrorSettings());
|
||||
json.put("error_marker", this.getErrorMarker());
|
||||
} catch (JSONException e) {
|
||||
logger.error("Error", e);
|
||||
} catch (JSONException ex) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
@ -3,12 +3,16 @@ package org.ccalm.translation.tools;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.MarkerFactory;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Storage implements AutoCloseable {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(Storage.class);
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Storage.class);
|
||||
|
||||
private Connection conn = null;
|
||||
|
||||
public Storage(){
|
||||
@ -29,8 +33,10 @@ public class Storage implements AutoCloseable {
|
||||
""";
|
||||
stmt.execute(sql);
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
logger.error("Error connecting or executing SQL query in SQLite", e);
|
||||
} catch (SQLException ex) {
|
||||
//logger.error("Error connecting or executing SQL query in SQLite", e);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,8 +47,10 @@ public class Storage implements AutoCloseable {
|
||||
try {
|
||||
conn.close();
|
||||
conn=null;
|
||||
} catch (SQLException e) {
|
||||
logger.error("SQLite close error", e);
|
||||
} catch (SQLException ex) {
|
||||
//logger.error("SQLite close error", e);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -77,10 +85,14 @@ public class Storage implements AutoCloseable {
|
||||
result.put("time_r", rs.getLong("time_r"));
|
||||
result.put("time_a", rs.getLong("time_a"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.error("An error occurred", e);
|
||||
} catch (Exception e) {
|
||||
logger.error("An error occurred", e);
|
||||
} catch (SQLException ex) {
|
||||
//logger.error("An error occurred", e);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||
} catch (Exception ex) {
|
||||
//logger.error("An error occurred", e);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -118,8 +130,10 @@ public class Storage implements AutoCloseable {
|
||||
insertStmt.close();
|
||||
}
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
logger.error("SQLite query execution error", e);
|
||||
} catch (SQLException ex) {
|
||||
//logger.error("SQLite query execution error", e);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -133,8 +147,10 @@ public class Storage implements AutoCloseable {
|
||||
if (rs.next()) {
|
||||
key = rs.getString("key");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.error("SQLite query execution error", e);
|
||||
} catch (SQLException ex) {
|
||||
//logger.error("SQLite query execution error", e);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||
}
|
||||
return key;
|
||||
}
|
||||
@ -148,8 +164,10 @@ public class Storage implements AutoCloseable {
|
||||
if (rs.next()) {
|
||||
time = rs.getLong("time_r");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.error("SQLite query execution error", e);
|
||||
} catch (SQLException ex) {
|
||||
//logger.error("SQLite query execution error", e);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||
}
|
||||
return time;
|
||||
}
|
||||
@ -160,8 +178,10 @@ public class Storage implements AutoCloseable {
|
||||
pstmt.setString(1, email);
|
||||
pstmt.executeUpdate();
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
logger.error("SQLite query execution error", e);
|
||||
} catch (SQLException ex) {
|
||||
//logger.error("SQLite query execution error", e);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,8 +4,11 @@ import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.ccalm.translation.MainController;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.MarkerFactory;
|
||||
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
@ -14,6 +17,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.security.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -23,7 +27,7 @@ import java.net.URL;
|
||||
|
||||
public class Tools {
|
||||
//---------------------------------------------------------------------------
|
||||
private static final Logger logger = LogManager.getLogger(Tools.class);
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Tools.class);
|
||||
//---------------------------------------------------------------------------
|
||||
public static JSONObject createJSONError(int code, String message, String setting, String marker) {
|
||||
JSONObject json = new JSONObject();
|
||||
@ -32,8 +36,9 @@ public class Tools {
|
||||
json.put("error_message", Arrays.asList(message));
|
||||
json.put("error_setting", Arrays.asList(setting));
|
||||
json.put("error_marker", marker);
|
||||
} catch (JSONException e) {
|
||||
logger.error(e);
|
||||
} catch (JSONException ex) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user