OpenKeyWord  Build_ID: 457, Datum: 01.02.2020 07:45:48
Dont repeat yourself. - Do it once and only once!
Log2Console.java
1  /*
2  ==============================================================================
3  Author: Zoltán Hrabovszki <zh@openkeyword.de>
4 
5  Copyright © 2012 - 2019 IT-Beratung Hrabovszki
6  www.OpenKeyWord.de
7  ==============================================================================
8 
9  This file is part of OpenKeyWord.
10 
11  OpenKeyWord is free software: you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenKeyWord is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenKeyWord. If not, see <http://www.gnu.org/licenses/>.
23 
24  Diese Datei ist Teil von OpenKeyWord.
25 
26  OpenKeyWord ist Freie Software: Sie können es unter den Bedingungen
27  der GNU General Public License, wie von der Free Software Foundation,
28  Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren
29  veröffentlichten Version, weiterverbreiten und/oder modifizieren.
30 
31  OpenKeyWord wird in der Hoffnung, dass es nützlich sein wird, aber
32  OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
33  Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
34  Siehe die GNU General Public License für weitere Details.
35 
36  Sie sollten eine Kopie der GNU General Public License zusammen mit
37  OpenKeyWord erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
38  */
39 
40 package okw.log;
41 
42 import java.util.List;
43 import okw.OKW_Helper;
44 
57 public class Log2Console implements ILogger
58 {
59 
60  private String BlanksBefore = "";
61  private int LevelCounter = 0;
62 
63  private Boolean cvbDebugMode = false;
64 
65 
66  public void reset()
67  {
68  LevelCounter = 0;
69  BlanksBefore = "";
70 
71  this.BlanksBefore();
72  }
73 
74 
78  @Override
79  public void LogError(String fps_Message)
80  {
81  System.out.println(this.BlanksBefore + OKW_Helper.repeatString("-", 80));
82  System.out.println(this.BlanksBefore + "ERROR: " + fps_Message);
83  System.out.println(this.BlanksBefore + OKW_Helper.repeatString("-", 80));
84  }
85 
86  @Override
90  public void LogException(String fps_Message)
91  {
92  System.out.print(this.BlanksBefore + "Exception: ");
93  System.out.println(fps_Message);
94  }
95 
96 
100  public void LogFunctionEnd()
101  {
102  this.LogPrint("-------");
103  this.ResCloseList();
104  }
105 
109  public void LogFunctionEnd(String fps_Return)
110  {
111  this.ResOpenList("Return...");
112  this.LogPrint(fps_Return);
113  this.ResCloseList();
114  this.LogPrint("-------");
115  this.ResCloseList();
116  }
117 
121  public void LogFunctionEnd(Boolean fpb_Return)
122  {
123  this.ResOpenList("Return...");
124  this.LogPrint(fpb_Return.toString());
125  this.ResCloseList();
126  this.LogPrint("-------");
127  this.ResCloseList();
128  }
129 
130 
134  public void LogFunctionEnd(List<String> fpls_Return)
135  {
136  this.ResOpenList("Return...");
137 
138  for (String Value : fpls_Return)
139  {
140  this.LogPrint(Value);
141  }
142 
143  this.ResCloseList();
144  this.LogPrint("-------");
145  this.ResCloseList();
146  }
147 
148 
152  public void LogFunctionStart(String fps_FunctionName, String... fpsParameter)
153  {
154  this.ResOpenList(fps_FunctionName);
155  this.ResOpenList("Parameter...");
156 
157  for (int i = 0; i < fpsParameter.length; i += 2)
158  {
159  this.LogPrint(fpsParameter[i] + ": >>" + fpsParameter[i + 1] + "<<");
160  }
161 
162  this.ResCloseList(); // Close Parameter List...
163  this.LogPrint("-------");
164  }
165 
166 
170  public void LogKeyWordEnd()
171  {
172  this.ResCloseList();
173  }
174 
175 
179  public void LogKeyWordStart(String fps_KeyWordName, String... fpsParameter)
180  {
181  String String2Print = fps_KeyWordName;
182 
183  // Keyword without parameter
184  if (fpsParameter.length == 0)
185  {
186  // Keyword with one Parameter
187  String2Print = String2Print + "()";
188  }
189  // Keyword with one Parameter
190  else if (fpsParameter.length == 1)
191  {
192  String2Print = String2Print + ": \"" + fpsParameter[0] + "\"";
193  }
194  // Keyword with two Parameters
195  else if (fpsParameter.length == 2)
196  {
197  String2Print = String2Print + ": \"" + fpsParameter[0] + "\" = \"" + fpsParameter[1] + "\"";
198  }
199  // Keyword with more then two Parameters
200  else
201  {
202  String2Print = String2Print + "(\"" + fpsParameter[0] + "\"";
203 
204  for (int i = 1; i < fpsParameter.length; i++)
205  {
206  String2Print = String2Print + ", \"" + fpsParameter[i] + "\"";
207  }
208 
209  String2Print = String2Print + ")";
210  }
211 
212  this.ResOpenList(String2Print);
213  }
214 
215 
219  public void LogLocalACCallStart( String sourceExcerpt, String Type )
220  {
221  this.ResOpenList( sourceExcerpt );
222  this.LogPrint( "Type: " + Type );
223  }
224 
225 
229  public void LogLocalACCallEnd()
230  {
231  this.ResCloseList();
232  }
233 
234 
238  public void LogRemoteACCallStart( String sourceExcerpt, String Type )
239  {
240  this.ResOpenList( sourceExcerpt );
241  this.LogPrint( "Type: " + Type );
242  }
243 
244 
248  public void LogRemoteACCallEnd()
249  {
250  this.ResCloseList();
251  }
252 
256  public void LogStepStart( String categoryName, String categoryType,
257  String choiceValue, String featureName,
258  String localCategoryName, String sourceExcerpt,
259  String type )
260  {
261  this.LogPrint( "Step: " + sourceExcerpt);
262  this.LevelCounter++;
263  this.LogPrint( " Feature Name:" + featureName);
264  this.LogPrint( " Category Name:" + categoryName );
265  this.LogPrint( " Category Type:" + categoryType );
266  this.LogPrint( " Choice Value:" + choiceValue);
267  this.LogPrint( "Local Category Name:" + localCategoryName);
268  this.LogPrint( " Type:" + type);
269  this.BlanksBefore();
270  }
271 
275  public void LogStepEnd()
276  {
277  this.ResCloseList();
278  }
279 
280 
284  public void LogPreconditionStart( String Gherkin )
285  {
286  this.ResOpenList( Gherkin );
287  }
288 
289 
293  public void LogPreconditionEnd()
294  {
295  this.ResCloseList();
296  }
297 
298 
299 
303  public void LogPostconditionStart( String Gherkin )
304  {
305  this.ResOpenList( Gherkin );
306  }
307 
308 
312  public void LogPostconditionEnd()
313  {
314  this.ResCloseList();
315  }
316 
320  public void LogPass( String fps_Message )
321  {
322  System.out.println(this.BlanksBefore + OKW_Helper.repeatString("-", 80));
323  System.out.println(this.BlanksBefore + "Pass: " + fps_Message);
324  System.out.println(this.BlanksBefore + OKW_Helper.repeatString("-", 80));
325  }
326 
327 
331  public void LogPrint(String fps_Message)
332  {
333  System.out.println(this.BlanksBefore + fps_Message);
334  }
335 
336 
337 
341  public void LogSourceLocation( String Start, String End, String featureName, String sourceType )
342  {
343  System.out.println(this.BlanksBefore + featureName);
344  System.out.println(this.BlanksBefore + Start);
345  System.out.println(this.BlanksBefore + End);
346  System.out.println(this.BlanksBefore + sourceType);
347  }
348 
349 
353  public void LogWarning(String fps_Message)
354  {
355  System.out.println(this.BlanksBefore + OKW_Helper.repeatString("-", 80));
356  System.out.println(this.BlanksBefore + "WARNING: " + fps_Message);
357  System.out.println(this.BlanksBefore + OKW_Helper.repeatString("-", 80));
358  }
359 
360 
364  public void ResCloseList()
365  {
366  if (this.LevelCounter > 0)
367  {
368  this.LevelCounter--;
369  }
370  else
371  {
372  this.LevelCounter = 0;
373  }
374 
375  this.BlanksBefore();
376  }
377 
378 
382  public void ResOpenList(String fps_Name)
383  {
384  this.LogPrint(fps_Name);
385  this.LevelCounter++;
386  this.BlanksBefore();
387  }
388 
389 
395  private void BlanksBefore()
396  {
397  this.BlanksBefore = OKW_Helper.repeatString( " ", this.LevelCounter);
398  }
399 
403  public void LogTestcaseStart( String fps_TestcaseName )
404  {
405  // Reset Log2Console
406  reset(); // Reset LevelCounter, BlanksBefor
407 
408  LogPrint("");
409  LogPrint("-------------------------------------------------------------------------");
410  LogKeyWordStart( "Testcase", fps_TestcaseName );
411  }
412 
413 
417  public void LogTestcaseEnd()
418  {
419  this.ResCloseList();
420  LogPrint("-------------------------------------------------------------------------");
421  }
422 
426  public void LogSequenceStart( String fps_KeyWordName, String fpsWindowFN,
427  String fps_SequenceName, String... fpsParameter )
428  {
429  int i = fpsParameter.length;
430  int n = i + 3;
431 
432  String[] newArray = new String[n];
433 
434  newArray[0] = fpsWindowFN;
435  newArray[1] = fps_SequenceName;
436 
437  for(int cnt=2; cnt<i; cnt++)
438  {
439  newArray[cnt] = fpsParameter[cnt-2];
440  }
441 
442  LogKeyWordStart( fps_KeyWordName, newArray );
443  }
444 
448  public void LogSequenceEnd()
449  {
450  this.ResCloseList();
451  }
452 
453 
457  public void LogFunctionStartDebug( String fps_FunctionName, String... fpsParameter )
458  {
459  if (this.cvbDebugMode)
460  {
461  LogFunctionStart(fps_FunctionName, fpsParameter);
462  }
463  }
464 
465 
469  public void LogFunctionEndDebug()
470  {
471  if (this.cvbDebugMode)
472  {
473  LogFunctionEnd();
474  }
475  }
476 
477 
481  public void LogFunctionEndDebug( Boolean fpb_Return )
482  {
483  if (this.cvbDebugMode)
484  {
485  LogFunctionEnd();
486  }
487  }
488 
492  public void LogFunctionEndDebug( String fps_Return )
493  {
494  if (this.cvbDebugMode)
495  {
496  LogFunctionEnd( fps_Return );
497  }
498  }
499 
503  public void LogFunctionEndDebug( List<String> fpLs_Return )
504  {
505  if (this.cvbDebugMode)
506  {
507  LogFunctionEnd( fpLs_Return );
508  }
509  }
510 
511 
515  public void LogPrintDebug( String fps_Message )
516  {
517  if (this.cvbDebugMode)
518  {
519  LogPrint( fps_Message );
520  }
521  }
522 
523 
527  public void ResOpenListDebug( String fps_Name )
528  {
529  if (this.cvbDebugMode)
530  {
531  ResOpenList( fps_Name );
532  }
533  }
534 
535 
536 
540  public void ResCloseListDebug()
541  {
542  if (this.cvbDebugMode)
543  {
544  ResCloseList( );
545  }
546  }
547 
551  public void setDebugMode( Boolean cvbDebugMode )
552  {
553  this.cvbDebugMode = cvbDebugMode;
554 
555  }
556 
557 
558 }
okw.log.Log2Console.LogError
void LogError(String fps_Message)
LogError: Logs an error message to the result.
Definition: Log2Console.java:79
okw.log.Log2Console.setDebugMode
void setDebugMode(Boolean cvbDebugMode)
setDebugMode:
Definition: Log2Console.java:551
okw.log.ILogger
Debug Logs are not a part of Interface.
Definition: ILogger.java:54
okw.log.Log2Console.LogPrint
void LogPrint(String fps_Message)
LogPrint: Prints the given message to the results.
Definition: Log2Console.java:331
okw.log.Log2Console.LogFunctionEnd
void LogFunctionEnd(List< String > fpls_Return)
LogFunctionEnd:
Definition: Log2Console.java:134
okw.log.Log2Console.LogRemoteACCallStart
void LogRemoteACCallStart(String sourceExcerpt, String Type)
LogRemoteACCallStart: Start of a remote AC call.
Definition: Log2Console.java:238
okw.log.Log2Console.LogPreconditionEnd
void LogPreconditionEnd()
Definition: Log2Console.java:293
okw.log.Log2Console.LogSequenceStart
void LogSequenceStart(String fps_KeyWordName, String fpsWindowFN, String fps_SequenceName, String... fpsParameter)
Definition: Log2Console.java:426
okw.log.Log2Console.LogFunctionEndDebug
void LogFunctionEndDebug()
LogFunctionEndDebug:
Definition: Log2Console.java:469
okw.log.Log2Console.LogFunctionStartDebug
void LogFunctionStartDebug(String fps_FunctionName, String... fpsParameter)
Definition: Log2Console.java:457
okw.log.Log2Console.LogWarning
void LogWarning(String fps_Message)
LogWarning: Logs an error message to the result.
Definition: Log2Console.java:353
okw.log.Log2Console.LogFunctionEndDebug
void LogFunctionEndDebug(List< String > fpLs_Return)
LogFunctionEndDebug:
Definition: Log2Console.java:503
okw.log.Log2Console.LogTestcaseEnd
void LogTestcaseEnd()
LogTestcaseEnd:
Definition: Log2Console.java:417
okw.log.Log2Console.LogPostconditionEnd
void LogPostconditionEnd()
Definition: Log2Console.java:312
okw.log.Log2Console
Klasse zur Ausgabe in die System.out.
Definition: Log2Console.java:57
okw.log.Log2Console.LogStepEnd
void LogStepEnd()
Definition: Log2Console.java:275
okw.log.Log2Console.LogKeyWordStart
void LogKeyWordStart(String fps_KeyWordName, String... fpsParameter)
Definition: Log2Console.java:179
okw.log.Log2Console.LogFunctionStart
void LogFunctionStart(String fps_FunctionName, String... fpsParameter)
Definition: Log2Console.java:152
okw.log.Log2Console.LogStepStart
void LogStepStart(String categoryName, String categoryType, String choiceValue, String featureName, String localCategoryName, String sourceExcerpt, String type)
LogStepStart: Log Begin of (Test) Step.
Definition: Log2Console.java:256
okw.log.Log2Console.ResCloseList
void ResCloseList()
ResCloseList: Closes the outline level.
Definition: Log2Console.java:364
okw.log.Log2Console.LogException
void LogException(String fps_Message)
LogException: Logs an exception to the results.
Definition: Log2Console.java:90
okw.log.Log2Console.LogSequenceEnd
void LogSequenceEnd()
LogSequenceEnd:
Definition: Log2Console.java:448
okw.log.Log2Console.LogFunctionEndDebug
void LogFunctionEndDebug(Boolean fpb_Return)
LogFunctionEndDebug(Boolean):
Definition: Log2Console.java:481
okw.log.Log2Console.LogPrintDebug
void LogPrintDebug(String fps_Message)
LogPrintDebug:
Definition: Log2Console.java:515
okw.log.Log2Console.LogTestcaseStart
void LogTestcaseStart(String fps_TestcaseName)
LogTestcaseStart:
Definition: Log2Console.java:403
okw.log.Log2Console.LogPass
void LogPass(String fps_Message)
LogPass: Logs an error message to the result.
Definition: Log2Console.java:320
okw.log.Log2Console.reset
void reset()
Method resets .
Definition: Log2Console.java:66
okw.OKW_Helper
Klasse enthält OKW-Hilfsfunktionen.
Definition: OKW_Helper.java:62
okw.log.Log2Console.LogSourceLocation
void LogSourceLocation(String Start, String End, String featureName, String sourceType)
LogSourceLocation: Logs location of Source in Harmony.
Definition: Log2Console.java:341
okw.log.Log2Console.BlanksBefore
void BlanksBefore()
Erzeugt die Einrücktiefe für die Console-Ausgabe.
Definition: Log2Console.java:395
okw.log.Log2Console.LogLocalACCallEnd
void LogLocalACCallEnd()
Definition: Log2Console.java:229
okw.log.Log2Console.LogRemoteACCallEnd
void LogRemoteACCallEnd()
LogRemoteACCallEnd: End of a remote AC call.
Definition: Log2Console.java:248
okw.log.Log2Console.LogKeyWordEnd
void LogKeyWordEnd()
LogKeyWordEnd:
Definition: Log2Console.java:170
okw.log.Log2Console.ResOpenListDebug
void ResOpenListDebug(String fps_Name)
Öffnet eine neue debug Ergenis-Ebene mit der gegebenen Überschrift.
Definition: Log2Console.java:527
okw.log.Log2Console.ResOpenList
void ResOpenList(String fps_Name)
LogFunctionStartDebug: Opens a debug outline level with the .
Definition: Log2Console.java:382
okw.log.Log2Console.LogFunctionEnd
void LogFunctionEnd(Boolean fpb_Return)
LogFunctionEnd(Boolean):
Definition: Log2Console.java:121
okw.log.Log2Console.LogLocalACCallStart
void LogLocalACCallStart(String sourceExcerpt, String Type)
Definition: Log2Console.java:219
okw.log.Log2Console.LogFunctionEnd
void LogFunctionEnd(String fps_Return)
LogFunctionEnd(String):
Definition: Log2Console.java:109
okw.log.Log2Console.LogPostconditionStart
void LogPostconditionStart(String Gherkin)
Definition: Log2Console.java:303
okw.log.Log2Console.ResCloseListDebug
void ResCloseListDebug()
ResCloseListDebug:
Definition: Log2Console.java:540
okw.log.Log2Console.LogPreconditionStart
void LogPreconditionStart(String Gherkin)
Definition: Log2Console.java:284
okw.log.Log2Console.LogFunctionEndDebug
void LogFunctionEndDebug(String fps_Return)
LogFunctionEndDebug(String):
Definition: Log2Console.java:492
okw.log.Log2Console.LogFunctionEnd
void LogFunctionEnd()
LogFunctionEnd:
Definition: Log2Console.java:100
okw.OKW_Helper.repeatString
static String repeatString(char c, Integer n)
Definition: OKW_Helper.java:816