Search in sources :

Example 1 with LoggingHierarchy

use of org.pentaho.di.core.logging.LoggingHierarchy in project pentaho-kettle by pentaho.

the class Trans method getLoggingHierarchy.

/**
 * Gets the logging hierarchy.
 *
 * @return the logging hierarchy
 */
public List<LoggingHierarchy> getLoggingHierarchy() {
    List<LoggingHierarchy> hierarchy = new ArrayList<>();
    List<String> childIds = LoggingRegistry.getInstance().getLogChannelChildren(getLogChannelId());
    for (String childId : childIds) {
        LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject(childId);
        if (loggingObject != null) {
            hierarchy.add(new LoggingHierarchy(getLogChannelId(), batchId, loggingObject));
        }
    }
    return hierarchy;
}
Also used : LoggingHierarchy(org.pentaho.di.core.logging.LoggingHierarchy) ArrayList(java.util.ArrayList) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface)

Example 2 with LoggingHierarchy

use of org.pentaho.di.core.logging.LoggingHierarchy in project pentaho-kettle by pentaho.

the class Job method writeLogChannelInformation.

/**
 * Write log channel information.
 *
 * @throws KettleException
 *           the kettle exception
 */
protected void writeLogChannelInformation() throws KettleException {
    Database db = null;
    ChannelLogTable channelLogTable = jobMeta.getChannelLogTable();
    // PDI-7070: If parent job has the same channel logging info, don't duplicate log entries
    Job j = getParentJob();
    if (j != null) {
        if (channelLogTable.equals(j.getJobMeta().getChannelLogTable())) {
            return;
        }
    }
    try {
        db = new Database(this, channelLogTable.getDatabaseMeta());
        db.shareVariablesWith(this);
        db.connect();
        db.setCommit(logCommitSize);
        List<LoggingHierarchy> loggingHierarchyList = getLoggingHierarchy();
        for (LoggingHierarchy loggingHierarchy : loggingHierarchyList) {
            db.writeLogRecord(channelLogTable, LogStatus.START, loggingHierarchy, null);
        }
        // Also time-out the log records in here...
        // 
        db.cleanupLogRecords(channelLogTable, getJobname());
    } catch (Exception e) {
        throw new KettleException(BaseMessages.getString(PKG, "Trans.Exception.UnableToWriteLogChannelInformationToLogTable"), e);
    } finally {
        if (!db.isAutoCommit()) {
            db.commit(true);
        }
        db.disconnect();
    }
}
Also used : LoggingHierarchy(org.pentaho.di.core.logging.LoggingHierarchy) KettleException(org.pentaho.di.core.exception.KettleException) ChannelLogTable(org.pentaho.di.core.logging.ChannelLogTable) Database(org.pentaho.di.core.database.Database) JobEntryJob(org.pentaho.di.job.entries.job.JobEntryJob) DuplicateParamException(org.pentaho.di.core.parameters.DuplicateParamException) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) KettleJobException(org.pentaho.di.core.exception.KettleJobException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException)

Example 3 with LoggingHierarchy

use of org.pentaho.di.core.logging.LoggingHierarchy in project pentaho-kettle by pentaho.

the class Job method getLoggingHierarchy.

/**
 * Gets the logging hierarchy.
 *
 * @return the logging hierarchy
 */
public List<LoggingHierarchy> getLoggingHierarchy() {
    List<LoggingHierarchy> hierarchy = new ArrayList<LoggingHierarchy>();
    List<String> childIds = LoggingRegistry.getInstance().getLogChannelChildren(getLogChannelId());
    for (String childId : childIds) {
        LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject(childId);
        if (loggingObject != null) {
            hierarchy.add(new LoggingHierarchy(getLogChannelId(), batchId, loggingObject));
        }
    }
    return hierarchy;
}
Also used : LoggingHierarchy(org.pentaho.di.core.logging.LoggingHierarchy) ArrayList(java.util.ArrayList) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface)

Example 4 with LoggingHierarchy

use of org.pentaho.di.core.logging.LoggingHierarchy in project pentaho-kettle by pentaho.

the class Trans method writeLogChannelInformation.

/**
 * Writes log channel information to a channel logging table (if one has been configured).
 *
 * @throws KettleException if any errors occur during logging
 */
protected void writeLogChannelInformation() throws KettleException {
    Database db = null;
    ChannelLogTable channelLogTable = transMeta.getChannelLogTable();
    // PDI-7070: If parent trans or job has the same channel logging info, don't duplicate log entries
    Trans t = getParentTrans();
    if (t != null) {
        if (channelLogTable.equals(t.getTransMeta().getChannelLogTable())) {
            return;
        }
    }
    Job j = getParentJob();
    if (j != null) {
        if (channelLogTable.equals(j.getJobMeta().getChannelLogTable())) {
            return;
        }
    }
    try {
        db = new Database(this, channelLogTable.getDatabaseMeta());
        db.shareVariablesWith(this);
        db.connect();
        db.setCommit(logCommitSize);
        List<LoggingHierarchy> loggingHierarchyList = getLoggingHierarchy();
        for (LoggingHierarchy loggingHierarchy : loggingHierarchyList) {
            db.writeLogRecord(channelLogTable, LogStatus.START, loggingHierarchy, null);
        }
        // Also time-out the log records in here...
        // 
        db.cleanupLogRecords(channelLogTable, getName());
    } catch (Exception e) {
        throw new KettleException(BaseMessages.getString(PKG, "Trans.Exception.UnableToWriteLogChannelInformationToLogTable"), e);
    } finally {
        disconnectDb(db);
    }
}
Also used : LoggingHierarchy(org.pentaho.di.core.logging.LoggingHierarchy) KettleException(org.pentaho.di.core.exception.KettleException) ChannelLogTable(org.pentaho.di.core.logging.ChannelLogTable) Database(org.pentaho.di.core.database.Database) Job(org.pentaho.di.job.Job) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleTransException(org.pentaho.di.core.exception.KettleTransException) DuplicateParamException(org.pentaho.di.core.parameters.DuplicateParamException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException)

Aggregations

LoggingHierarchy (org.pentaho.di.core.logging.LoggingHierarchy)4 ArrayList (java.util.ArrayList)2 Database (org.pentaho.di.core.database.Database)2 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)2 KettleException (org.pentaho.di.core.exception.KettleException)2 KettleValueException (org.pentaho.di.core.exception.KettleValueException)2 ChannelLogTable (org.pentaho.di.core.logging.ChannelLogTable)2 LoggingObjectInterface (org.pentaho.di.core.logging.LoggingObjectInterface)2 DuplicateParamException (org.pentaho.di.core.parameters.DuplicateParamException)2 UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)2 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 KettleFileException (org.pentaho.di.core.exception.KettleFileException)1 KettleJobException (org.pentaho.di.core.exception.KettleJobException)1 KettleTransException (org.pentaho.di.core.exception.KettleTransException)1 Job (org.pentaho.di.job.Job)1 JobEntryJob (org.pentaho.di.job.entries.job.JobEntryJob)1