Unverified Commit 91dad8a6 authored by Kristof Szabados's avatar Kristof Szabados Committed by GitHub
Browse files

Merge pull request #378 from GergoUjhelyi/master

first methods to log into files
parents 1dea714a abc1f3ac
......@@ -14,4 +14,9 @@ package org.eclipse.titan.runtime.core;
*/
public interface ILoggerPlugin {
void log(final TitanLoggerApi.TitanLogEvent event, final boolean log_buffered, final boolean separate_file, final boolean use_emergency_mask);
void set_file_name(final String new_filename_skeleton, final boolean from_config);
void set_append_file(final boolean new_append_file);
boolean set_file_size(final int p_size);
boolean set_file_number(final int p_number);
boolean set_disk_full_action(final TtcnLogger.disk_full_action_t p_disk_full_action);
}
......@@ -66,6 +66,16 @@ public class LegacyLogger implements ILoggerPlugin {
* This function represents the entry point for the legacy style logger plugin.
* (still embedded in this generic class while transitioning the design)
* */
private String filename_skeleton_;
private TtcnLogger.disk_full_action_t disk_full_action_;
private boolean skeleton_given_;
private boolean append_file_;
private boolean is_disk_full_;
private String current_filename_;
private int logfile_size_;
private int logfile_number_;
public void log(final TitanLoggerApi.TitanLogEvent event, final boolean log_buffered, final boolean separate_file, final boolean use_emergency_mask) {
if (separate_file) {
//FIXME implement
......@@ -86,6 +96,33 @@ public class LegacyLogger implements ILoggerPlugin {
}
}
public void set_file_name(String new_filename_skeleton, boolean from_config) {
filename_skeleton_ = "";
filename_skeleton_ = new_filename_skeleton;
if (from_config) {
skeleton_given_ = true;
}
}
public void set_append_file(boolean new_append_file) {
append_file_ = new_append_file;
}
public boolean set_file_size(int p_size) {
logfile_size_ = p_size;
return true;
}
public boolean set_file_number(int p_number) {
logfile_number_ = p_number;
return true;
}
public boolean set_disk_full_action(TtcnLogger.disk_full_action_t p_disk_full_action) {
disk_full_action_ = p_disk_full_action;
return true;
}
/**
* The log_console function from the legacy logger.
*
......
......@@ -59,6 +59,7 @@ import org.eclipse.titan.runtime.core.TitanLoggerApi.TitanLogEvent_sourceInfo__l
import org.eclipse.titan.runtime.core.TitanVerdictType.VerdictTypeEnum;
import org.eclipse.titan.runtime.core.TtcnLogger.Severity;
import org.eclipse.titan.runtime.core.TtcnLogger.TTCN_Location;
import org.eclipse.titan.runtime.core.TtcnLogger.component_id_t;
import org.eclipse.titan.runtime.core.TtcnLogger.emergency_logging_behaviour_t;
import org.eclipse.titan.runtime.core.TtcnLogger.extcommand_t;
......@@ -189,6 +190,58 @@ public class LoggerPluginManager {
}
}
public void set_file_name(final String new_filename_skeleton, boolean from_config) {
for (int i = 0; i < plugins_.size(); i++) {
plugins_.get(i).set_file_name(new_filename_skeleton, from_config);
}
}
public void set_append_file(boolean new_append_file) {
for (int i = 0; i < plugins_.size(); i++) {
plugins_.get(i).set_append_file(new_append_file);
}
}
public boolean set_file_size(final component_id_t comp, int p_size) {
boolean ret_val = false;
for (int i = 0; i < plugins_.size(); i++) {
if (plugins_.get(i).set_file_size(p_size)) {
ret_val = true;
}
}
return ret_val;
}
public boolean set_file_number(final component_id_t cmpt, int p_number) {
boolean ret_val = false;
for (int i = 0; i < plugins_.size(); i++) {
if (plugins_.get(i).set_file_number(p_number)) {
ret_val = true;
}
}
return ret_val;
}
public boolean set_disk_full_action(final component_id_t comp, TtcnLogger.disk_full_action_t p_disk_full_action) {
boolean ret_val = false;
for (int i = 0; i < plugins_.size(); i++) {
if (plugins_.get(i).set_disk_full_action(p_disk_full_action)) {
ret_val = true;
}
}
return ret_val;
}
public void open_file() {
//FIXME: implement
}
public void close_file() {
//FIXME: implement
}
public void begin_event(final Severity msg_severity) {
final log_event_struct temp = new log_event_struct();
......
......@@ -153,6 +153,17 @@ public final class TtcnLogger {
}
}
public static class disk_full_action_t {
disk_full_action_type_t type;
int retry_interval;
public disk_full_action_t(disk_full_action_type_t disk_type, int retry) {
type = disk_type;
retry_interval = retry;
}
}
public static enum disk_full_action_type_t {DISKFULL_ERROR, DISKFULL_STOP, DISKFULL_RETRY, DISKFULL_DELETE};
public static enum timestamp_format_t {TIMESTAMP_TIME, TIMESTAMP_DATETIME, TIMESTAMP_SECONDS};
public static enum source_info_format_t {SINFO_NONE, SINFO_SINGLE, SINFO_STACK };
public static enum log_event_types_t {LOGEVENTTYPES_NO, LOGEVENTTYPES_YES, LOGEVENTTYPES_SUBCATEGORIES};
......@@ -1003,6 +1014,10 @@ public final class TtcnLogger {
get_logger_plugin_manager().log_port_queue(operation, port_name, componentReference, id, address, parameter);
}
public static void set_file_name(final String new_filename_skeleton, boolean from_config) {
get_logger_plugin_manager().set_file_name(new_filename_skeleton , from_config);
}
public static void set_start_time() {
start_time = System.currentTimeMillis();
}
......@@ -1052,6 +1067,30 @@ public final class TtcnLogger {
}
}
public static void set_append_file(boolean new_append_file) {
get_logger_plugin_manager().set_append_file(new_append_file);
}
public static boolean set_file_size(final component_id_t comp, int p_size) {
return get_logger_plugin_manager().set_file_size(comp, p_size);
}
public static boolean set_file_number(final component_id_t comp, int p_number) {
return get_logger_plugin_manager().set_file_number(comp, p_number);
}
public static boolean set_disk_full_action(final component_id_t comp, disk_full_action_t p_disk_full_action) {
return get_logger_plugin_manager().set_disk_full_action(comp, p_disk_full_action);
}
public static void open_file() {
get_logger_plugin_manager().open_file();
}
public static void close_file() {
get_logger_plugin_manager().close_file();
}
public static void set_emergency_logging_behaviour(final emergency_logging_behaviour_t behaviour){
emergency_logging_behaviour=behaviour;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment