IDEMPIERE-6044 CLogMgt.enable not working properly after InitialClientSetup (#2328)
* IDEMPIERE-6044 CLogMgt.enable not working properly after InitialClientSetup * - add deprecation comment
This commit is contained in:
parent
7d70e4ef02
commit
44688e37a1
|
|
@ -47,11 +47,6 @@ import javax.print.attribute.standard.JobPriority;
|
||||||
import javax.print.attribute.standard.OrientationRequested;
|
import javax.print.attribute.standard.OrientationRequested;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
|
|
||||||
import org.adempiere.process.UUIDGenerator;
|
|
||||||
import org.compiere.model.MColumn;
|
|
||||||
import org.compiere.model.PO;
|
|
||||||
import org.compiere.model.X_AD_PrintForm;
|
|
||||||
import org.compiere.util.CLogMgt;
|
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
|
@ -453,8 +448,7 @@ public class PrintUtil
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config("AD_Client_ID=" + AD_Client_ID);
|
if (log.isLoggable(Level.CONFIG)) log.config("AD_Client_ID=" + AD_Client_ID);
|
||||||
Properties ctx = Env.getCtx();
|
Properties ctx = Env.getCtx();
|
||||||
CLogMgt.enable(false);
|
|
||||||
//
|
|
||||||
// Order Template
|
// Order Template
|
||||||
int Order_PrintFormat_ID = MPrintFormat.copyToClient(ctx, PRINTFORMAT_ORDER_HEADER_TEMPLATE, AD_Client_ID, trxName).get_ID();
|
int Order_PrintFormat_ID = MPrintFormat.copyToClient(ctx, PRINTFORMAT_ORDER_HEADER_TEMPLATE, AD_Client_ID, trxName).get_ID();
|
||||||
int OrderLine_PrintFormat_ID = MPrintFormat.copyToClient(ctx, PRINTFORMAT_ORDER_LINETAX_TEMPLATE, AD_Client_ID, trxName).get_ID();
|
int OrderLine_PrintFormat_ID = MPrintFormat.copyToClient(ctx, PRINTFORMAT_ORDER_LINETAX_TEMPLATE, AD_Client_ID, trxName).get_ID();
|
||||||
|
|
@ -475,27 +469,18 @@ public class PrintUtil
|
||||||
int Remittance_PrintFormat_ID = MPrintFormat.copyToClient(ctx, PRINTFORMAT_PAYSELECTION_REMITTANCE__TEMPLATE, AD_Client_ID, trxName).get_ID();
|
int Remittance_PrintFormat_ID = MPrintFormat.copyToClient(ctx, PRINTFORMAT_PAYSELECTION_REMITTANCE__TEMPLATE, AD_Client_ID, trxName).get_ID();
|
||||||
updatePrintFormatHeader(Remittance_PrintFormat_ID, RemittanceLine_PrintFormat_ID, trxName);
|
updatePrintFormatHeader(Remittance_PrintFormat_ID, RemittanceLine_PrintFormat_ID, trxName);
|
||||||
|
|
||||||
// TODO: MPrintForm
|
|
||||||
|
|
||||||
int AD_PrintForm_ID = DB.getNextID (AD_Client_ID, "AD_PrintForm", null);
|
int AD_PrintForm_ID = DB.getNextID (AD_Client_ID, "AD_PrintForm", null);
|
||||||
String sql = "INSERT INTO AD_PrintForm(AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_PrintForm_ID,"
|
StringBuilder sql = new StringBuilder("INSERT INTO AD_PrintForm(AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_PrintForm_ID,AD_PrintForm_UU,"
|
||||||
+ "Name,Order_PrintFormat_ID,Invoice_PrintFormat_ID,Remittance_PrintFormat_ID,Shipment_PrintFormat_ID)"
|
+ "Name,Order_PrintFormat_ID,Invoice_PrintFormat_ID,Remittance_PrintFormat_ID,Shipment_PrintFormat_ID)"
|
||||||
//
|
+ " VALUES (")
|
||||||
+ " VALUES (" + AD_Client_ID + ",0,'Y',getDate(),0,getDate(),0," + AD_PrintForm_ID + ","
|
.append(AD_Client_ID).append(",0,'Y',getDate(),0,getDate(),0,").append(AD_PrintForm_ID).append(",generate_uuid(),")
|
||||||
+ "'" + Msg.translate(ctx, "Standard") + "',"
|
.append(DB.TO_STRING(Msg.translate(ctx, "Standard"))).append(",")
|
||||||
+ Order_PrintFormat_ID + "," + Invoice_PrintFormat_ID + ","
|
.append(Order_PrintFormat_ID).append(",").append(Invoice_PrintFormat_ID).append(",")
|
||||||
+ Remittance_PrintFormat_ID + "," + Shipment_PrintFormat_ID + ")";
|
.append(Remittance_PrintFormat_ID).append(",").append(Shipment_PrintFormat_ID).append(")");
|
||||||
int no = DB.executeUpdate(sql, trxName);
|
int no = DB.executeUpdateEx(sql.toString(), trxName);
|
||||||
if (no != 1)
|
if (no != 1)
|
||||||
log.log(Level.SEVERE, "PrintForm NOT inserted");
|
log.log(Level.SEVERE, "PrintForm NOT inserted");
|
||||||
|
|
||||||
if (DB.isGenerateUUIDSupported())
|
|
||||||
DB.executeUpdateEx("UPDATE AD_PrintForm SET AD_PrintForm_UU=generate_uuid() WHERE AD_PrintForm_UU IS NULL", trxName);
|
|
||||||
else
|
|
||||||
UUIDGenerator.updateUUID(MColumn.get(ctx, X_AD_PrintForm.Table_Name, PO.getUUIDColumnName(X_AD_PrintForm.Table_Name)), trxName);
|
|
||||||
|
|
||||||
//
|
|
||||||
CLogMgt.enable(true);
|
|
||||||
} // createDocuments
|
} // createDocuments
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -450,18 +450,31 @@ public class CLogMgt
|
||||||
return Level.INFO.intValue() >= getLevelAsInt();
|
return Level.INFO.intValue() >= getLevelAsInt();
|
||||||
} // isLevelFine
|
} // isLevelFine
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the current level when disabling log
|
||||||
|
*/
|
||||||
|
private static Level previousLevel = null;
|
||||||
/**
|
/**
|
||||||
* Enable/Disable logging (of handlers)
|
* Enable/Disable logging (of handlers)
|
||||||
* @param enableLogging true if logging enabled
|
* @param enableLogging true if logging enabled
|
||||||
|
* @deprecated not recommended to use, problematic method to enable/disable the log globally
|
||||||
*/
|
*/
|
||||||
public static void enable (boolean enableLogging)
|
public static void enable (boolean enableLogging)
|
||||||
{
|
{
|
||||||
Logger rootLogger = getRootLogger();
|
Logger rootLogger = getRootLogger();
|
||||||
|
|
||||||
if (enableLogging)
|
if (enableLogging)
|
||||||
|
{
|
||||||
|
if (previousLevel != null)
|
||||||
|
setLevel(previousLevel);
|
||||||
|
else
|
||||||
setLevel(rootLogger.getLevel());
|
setLevel(rootLogger.getLevel());
|
||||||
|
reInit();
|
||||||
|
previousLevel = null;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
previousLevel = rootLogger.getLevel();
|
||||||
setLevel(Level.OFF);
|
setLevel(Level.OFF);
|
||||||
}
|
}
|
||||||
} // enable
|
} // enable
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue