2 % A node where jobs are logged upon passage.
4 % Copyright (c) 2012-2026, Imperial College London
15 properties (Access=
private)
27 function self = Logger(model, name, logFileName)
28 % SELF = LOGGER(MODEL, NAME, LOGFILENAME)
31 if model.isMatlabNative()
32 [~,fileName,fileExt] = fileparts(logFileName);
33 self.fileName = sprintf('%s%s',fileName,fileExt);
34 if isempty(model.getLogPath)
35 line_error(mfilename,'To instantiate a Logger, first use setLogPath method on the Network
object to define the global path to save logs.');
37 self.filePath = model.getLogPath;
41 self.output = Dispatcher(
classes);
43 self.schedPolicy = SchedStrategyType.NP;
44 self.schedStrategy = SchedStrategy.FCFS;
45 self.server = LogTunnel();
46 self.setStartTime(false);
47 self.setLoggerName(false);
48 self.setTimestamp(true);
50 self.setJobClass(true);
51 self.setTimeSameClass(false);
52 self.setTimeAnyClass(false);
54 self.model.addNode(self);
55 elseif model.isJavaNative()
57 self.obj = jline.lang.
nodes.Logger(model.obj, name, logFileName);
58 self.index = model.obj.getNodeIndex(self.obj);
62 function ret = getStartTime(self)
63 % RET = GETSTARTTIME()
65 ret = self.wantStartTime;
67 function ret = getLoggerName(self)
68 % RET = GETLOGGERNAME()
70 ret = self.wantLoggerName;
72 function ret = getTimestamp(self)
73 % RET = GETTIMESTAMP()
75 ret = self.wantTimestamp;
77 function ret = getJobID(self)
82 function ret = getJobClass(self)
85 ret = self.wantJobClass;
87 function ret = getTimeSameClass(self)
88 % RET = GETTIMESAMECLASS()
90 ret = self.wantTimeSameClass;
92 function ret = getTimeAnyClass(self)
93 % RET = GETTIMEANYCLASS()
95 ret = self.wantTimeAnyClass;
98 function setStartTime(self,
bool)
102 self.wantStartTime = 'true';
104 self.wantStartTime = 'false';
108 function setTimestamp(self,
bool)
112 self.wantTimestamp = 'true';
114 self.wantTimestamp = 'false';
118 function setLoggerName(self,
bool)
119 % SETLOGGERNAME(BOOL)
122 self.wantLoggerName = 'true';
124 self.wantLoggerName = 'false';
128 function setTimeSameClass(self,
bool)
129 % SETTIMESAMECLASS(BOOL)
132 self.wantTimeSameClass = 'true';
134 self.wantTimeSameClass = 'false';
138 function setTimeAnyClass(self,
bool)
139 % SETTIMEANYCLASS(BOOL)
142 self.wantTimeAnyClass = 'true';
144 self.wantTimeAnyClass = 'false';
148 function setJobID(self,
bool)
152 self.wantJobID = 'true';
154 self.wantJobID = 'false';
158 function setJobClass(self,
bool)
162 self.wantJobClass = 'true';
164 self.wantJobClass = 'false';
168 function setProbRouting(self, class, destination, probability)
169 % SETPROBROUTING(CLASS, DESTINATION, PROBABILITY)
171 setRouting(self, class, RoutingStrategy.PROB, destination, probability);