25
25
import java.util.Date;
26
26
import java.util.Iterator;
27
27
import java.util.LinkedList;
28
import javax.swing.SwingUtilities;
28
29
import mediathek.daten.Daten;
30
import mediathek.gui.dialogEinstellungen.PanelMeldungen;
29
31
import mediathek.tool.Funktionen;
30
32
import mediathek.tool.Konstanten;
31
33
import mediathek.tool.ListenerMediathekView;
39
41
public static final int LOG_FEHLER = ListenerMediathekView.EREIGNIS_LOG_FEHLER;
40
42
public static final int LOG_SYSTEM = ListenerMediathekView.EREIGNIS_LOG_SYSTEM;
41
43
public static final int LOG_PLAYER = ListenerMediathekView.EREIGNIS_LOG_PLAYER;
42
public static final int FEHLER_ART_PROG = 0;
43
public static final String FEHLER_ART_PROG_TEXT = " Prog: ";
44
public static final int FEHLER_ART_GETURL = 1;
45
public static final String FEHLER_ART_GETURL_TEXT = " GetUrl: ";
46
public static final int FEHLER_ART_MREADER = 2;
47
public static final String FEHLER_ART_MREADER_TEXT = "MReader: ";
48
public static final int FEHLER_ART_FILME_SUCHEN = 3;
49
public static final String FEHLER_ART_FILME_SUCHEN_TEXT = " Filme: ";
50
public static final int FEHLER_ART_AUTO = 4;
51
public static final String FEHLER_ART_AUTO_TEXT = " Auto: ";
52
public static final int FEHLER_ART_NOGUI = 5;
53
public static final String FEHLER_ART_NOGUI_TEXT = " NoGui: ";
54
//public static final int FEHLER_ART_MAX = 6;
56
45
private static final int MAX_LAENGE_1 = 50000;
57
46
private static final int MAX_LAENGE_2 = 30000;
58
47
private static int zeilenNrSystem = 0;
59
48
private static int zeilenNrProgramm = 0;
60
49
private static int zeilenNrFehler = 0;
61
private static final LinkedList<Integer[]> fehlerListe = new LinkedList<>(); // [Art, Fehlernummer, Anzahl, Exception(0,1 für ja, nein)]
50
private static final LinkedList<Integer[]> fehlerListe = new LinkedList<>(); // [Fehlernummer, Anzahl, Exception(0,1 für ja, nein)]
62
51
private static final boolean progress = false;
63
52
private static final String progressText = "";
64
53
private static final Date startZeit = new Date(System.currentTimeMillis());
54
public static PanelMeldungen panelMeldungenFehler = null; // unschön, gab aber sonst einen Deadlock mit notifyMediathekListener
55
public static PanelMeldungen panelMeldungenSystem = null;
56
public static PanelMeldungen panelMeldungenPlayer = null;
66
58
public static synchronized void versionsMeldungen(String classname) {
67
59
final SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
101
93
Log.systemMeldung("");
104
public static synchronized void debugMeldung(String text) {
110
96
// Fehlermeldung mit Exceptions
111
public static synchronized void fehlerMeldung(int fehlerNummer, int art, String klasse, Exception ex) {
112
fehlermeldung_(fehlerNummer, art, klasse, ex, new String[]{});
115
public static synchronized void fehlerMeldung(int fehlerNummer, int art, String klasse, Exception ex, String text) {
116
fehlermeldung_(fehlerNummer, art, klasse, ex, new String[]{text});
119
public static synchronized void fehlerMeldung(int fehlerNummer, int art, String klasse, Exception ex, String text[]) {
120
fehlermeldung_(fehlerNummer, art, klasse, ex, text);
97
public static synchronized void fehlerMeldung(int fehlerNummer, String klasse, Exception ex) {
98
fehlermeldung_(fehlerNummer, klasse, ex, new String[]{});
101
public static synchronized void fehlerMeldung(int fehlerNummer, String klasse, Exception ex, String text) {
102
fehlermeldung_(fehlerNummer, klasse, ex, new String[]{text});
105
public static synchronized void fehlerMeldung(int fehlerNummer, String klasse, Exception ex, String text[]) {
106
fehlermeldung_(fehlerNummer, klasse, ex, text);
123
109
// Fehlermeldungen
124
public static synchronized void fehlerMeldung(int fehlerNummer, int art, String klasse, String text) {
125
fehlermeldung_(fehlerNummer, art, klasse, null, new String[]{text});
110
public static synchronized void fehlerMeldung(int fehlerNummer, String klasse, String text) {
111
fehlermeldung_(fehlerNummer, klasse, null, new String[]{text});
128
public static synchronized void fehlerMeldung(int fehlerNummer, int art, String klasse, String[] text) {
129
fehlermeldung_(fehlerNummer, art, klasse, null, text);
114
public static synchronized void fehlerMeldung(int fehlerNummer, String klasse, String[] text) {
115
fehlermeldung_(fehlerNummer, klasse, null, text);
132
118
public static synchronized void systemMeldung(String[] text) {
184
170
for (int i = 1; i < fehlerListe.size(); ++i) {
185
171
for (int k = i; k > 0; --k) {
186
i_1 = fehlerListe.get(k - 1)[1];
187
i_2 = fehlerListe.get(k)[1];
172
i_1 = fehlerListe.get(k - 1)[0];
173
i_2 = fehlerListe.get(k)[0];
188
174
// if (str1.compareToIgnoreCase(str2) > 0) {
190
176
fehlerListe.add(k - 1, fehlerListe.remove(k));
196
182
for (Integer[] integers : fehlerListe) {
198
switch (integers[0]) {
199
case FEHLER_ART_MREADER:
200
z = FEHLER_ART_MREADER_TEXT;
202
case FEHLER_ART_FILME_SUCHEN:
203
z = FEHLER_ART_FILME_SUCHEN_TEXT;
205
case FEHLER_ART_GETURL:
206
z = FEHLER_ART_GETURL_TEXT;
208
case FEHLER_ART_PROG:
209
z = FEHLER_ART_PROG_TEXT;
211
case FEHLER_ART_NOGUI:
212
z = FEHLER_ART_NOGUI_TEXT;
214
case FEHLER_ART_AUTO:
215
z = FEHLER_ART_AUTO_TEXT;
220
boolean ex = integers[3] == 1;
183
boolean ex = integers[2] == 1;
227
if (integers[1] < 0) {
228
systemMeldung(strEx + z + " Fehlernummer: " + integers[1] + " Anzahl: " + integers[2]);
190
if (integers[0] < 0) {
191
systemMeldung(strEx + " Fehlernummer: " + integers[0] + " Anzahl: " + integers[1]);
230
systemMeldung(strEx + z + " Fehlernummer: " + integers[1] + " Anzahl: " + integers[2]);
193
systemMeldung(strEx + " Fehlernummer: " + integers[0] + " Anzahl: " + integers[1]);
247
210
for (int i = 1; i < fehlerListe.size(); ++i) {
248
211
for (int k = i; k > 0; --k) {
249
i_1 = fehlerListe.get(k - 1)[1];
250
i_2 = fehlerListe.get(k)[1];
212
i_1 = fehlerListe.get(k - 1)[0];
213
i_2 = fehlerListe.get(k)[0];
251
214
// if (str1.compareToIgnoreCase(str2) > 0) {
253
216
fehlerListe.add(k - 1, fehlerListe.remove(k));
259
222
for (Integer[] integers : fehlerListe) {
261
switch (integers[0]) {
262
case FEHLER_ART_MREADER:
263
z = FEHLER_ART_MREADER_TEXT;
265
case FEHLER_ART_FILME_SUCHEN:
266
z = FEHLER_ART_FILME_SUCHEN_TEXT;
268
case FEHLER_ART_GETURL:
269
z = FEHLER_ART_GETURL_TEXT;
271
case FEHLER_ART_PROG:
272
z = FEHLER_ART_PROG_TEXT;
274
case FEHLER_ART_NOGUI:
275
z = FEHLER_ART_NOGUI_TEXT;
277
case FEHLER_ART_AUTO:
278
z = FEHLER_ART_AUTO_TEXT;
283
boolean ex = integers[3] == 1;
223
boolean ex = integers[2] == 1;
290
if (integers[1] < 0) {
291
ret += strEx + z + " Fehlernummer: " + integers[1] + " Anzahl: " + integers[2] + "\n";
230
if (integers[0] < 0) {
231
ret += strEx + " Fehlernummer: " + integers[0] + " Anzahl: " + integers[1] + "\n";
293
ret += strEx + z + " Fehlernummer: " + integers[1] + " Anzahl: " + integers[2] + "\n";
233
ret += strEx + " Fehlernummer: " + integers[0] + " Anzahl: " + integers[1] + "\n";
302
private static void addFehlerNummer(int nr, int art, boolean exception) {
242
private static void addFehlerNummer(int nr, boolean exception) {
303
243
Iterator<Integer[]> it = fehlerListe.iterator();
304
244
int ex = exception ? 1 : 2;
305
245
while (it.hasNext()) {
306
246
Integer[] i = it.next();
314
253
// dann gibts die Nummer noch nicht
315
fehlerListe.add(new Integer[]{art, nr, 1, ex});
254
fehlerListe.add(new Integer[]{nr, 1, ex});
318
private static void fehlermeldung_(int fehlerNummer, int art, String klasse, Exception ex, String[] texte) {
319
addFehlerNummer(fehlerNummer, art, ex != null);
257
private static void fehlermeldung_(int fehlerNummer, String klasse, Exception ex, String[] texte) {
258
addFehlerNummer(fehlerNummer, ex != null);
320
259
if (ex != null || Daten.debug) {
322
261
String s = getStackTrace(ex);
339
case FEHLER_ART_MREADER:
342
case FEHLER_ART_FILME_SUCHEN:
345
case FEHLER_ART_GETURL:
348
case FEHLER_ART_PROG:
349
case FEHLER_ART_NOGUI:
350
case FEHLER_ART_AUTO:
354
278
System.out.println(x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x);
355
279
System.out.println(z + " Fehlernr: " + fehlerNummer);
356
280
if (ex != null) {
357
281
System.out.println(z + " Exception: " + ex.getMessage());
359
283
System.out.println(z + " " + FEHLER + klasse);
360
notifyMediathekListener(LOG_FEHLER, FEHLER + klasse);
284
notifyPanelMeldung(LOG_FEHLER, FEHLER + klasse);
361
285
for (String text : texte) {
362
286
System.out.println(z + " " + text);
363
notifyMediathekListener(LOG_FEHLER, text);
287
notifyPanelMeldung(LOG_FEHLER, text);
365
289
System.out.println("");
388
301
final String z = ". ";
389
302
if (texte.length <= 1) {
390
303
System.out.println(z + " " + texte[0]);
391
notifyMediathekListener(LOG_SYSTEM, texte[0]);
304
notifyPanelMeldung(LOG_SYSTEM, texte[0]);
393
306
String zeile = "---------------------------------------";
395
308
System.out.println(z + zeile);
396
notifyMediathekListener(LOG_SYSTEM, zeile);
309
notifyPanelMeldung(LOG_SYSTEM, zeile);
397
310
for (int i = 0; i < texte.length; ++i) {
398
311
txt = "| " + texte[i];
399
312
System.out.println(z + txt);
401
notifyMediathekListener(LOG_SYSTEM, texte[i]);
314
notifyPanelMeldung(LOG_SYSTEM, texte[i]);
403
notifyMediathekListener(LOG_SYSTEM, " " + texte[i]);
316
notifyPanelMeldung(LOG_SYSTEM, " " + texte[i]);
406
notifyMediathekListener(LOG_SYSTEM, " ");
319
notifyPanelMeldung(LOG_SYSTEM, " ");
407
320
System.out.println(z + zeile);
419
332
final String z = " >>";
420
333
System.out.println(z + " " + texte[0]);
421
notifyMediathekListener(LOG_PLAYER, texte[0]);
334
notifyPanelMeldung(LOG_PLAYER, texte[0]);
422
335
for (int i = 1; i < texte.length; ++i) {
423
336
System.out.println(z + " " + texte[i]);
424
notifyMediathekListener(LOG_PLAYER, texte[i]);
337
notifyPanelMeldung(LOG_PLAYER, texte[i]);
427
340
System.out.print(progressText);
439
352
zeilenNrProgramm = 0;
440
353
textProgramm.setLength(0);
442
ListenerMediathekView.notify(art, Log.class.getName());
445
private static void notifyMediathekListener(int art, String zeile) {
357
private static void notifyPanelMeldung(int art, String zeile) {
446
358
if (art == LOG_FEHLER) {
447
359
addText(textFehler, "[" + getNr(zeilenNrFehler++) + "] " + zeile);
448
360
} else if (art == LOG_SYSTEM) {
450
362
} else if (art == LOG_PLAYER) {
451
363
addText(textProgramm, "[" + getNr(zeilenNrProgramm++) + "] " + zeile);
453
ListenerMediathekView.notify(art, Log.class.getName());
368
private static void notifyPanel(int art) {
371
if (SwingUtilities.isEventDispatchThread()) {
373
if (art == LOG_FEHLER && panelMeldungenFehler != null) {
374
panelMeldungenFehler.notifyPanel();
375
} else if (art == LOG_SYSTEM && panelMeldungenSystem != null) {
376
panelMeldungenSystem.notifyPanel();
377
} else if (art == LOG_PLAYER && panelMeldungenPlayer != null) {
378
panelMeldungenPlayer.notifyPanel();
381
SwingUtilities.invokeLater(new Runnable() {
385
if (a == LOG_FEHLER && panelMeldungenFehler != null) {
386
panelMeldungenFehler.notifyPanel();
387
} else if (a == LOG_SYSTEM && panelMeldungenSystem != null) {
388
panelMeldungenSystem.notifyPanel();
389
} else if (a == LOG_PLAYER && panelMeldungenPlayer != null) {
390
panelMeldungenPlayer.notifyPanel();
395
} catch (Exception ex) {
396
Log.fehlerMeldung(698989743, "ListenerMediathekView.pingen", ex);
456
400
private static String getStackTrace(Throwable t) {