~ubuntu-branches/ubuntu/vivid/mediathekview/vivid

« back to all changes in this revision

Viewing changes to src/mediathek/controller/Log.java

  • Committer: Package Import Robot
  • Author(s): Markus Koschany
  • Date: 2014-10-24 12:49:46 UTC
  • mfrom: (4.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20141024124946-rhnmiwad6apojoxt
Tags: 7.1-1
* Imported Upstream version 7.1.
* Declare compliance with Debian Policy 3.9.6.
* Update VCS-Browser field to new canonical address.
* Update man pages timestamp.
* Update debian/copyright for new release.
* Add README.source.
* Rename modify-ant-build-system.patch to build.patch and update it for 7.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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;
55
44
 
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;
65
57
 
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("");
102
94
    }
103
95
 
104
 
    public static synchronized void debugMeldung(String text) {
105
 
        if (Daten.debug) {
106
 
            debugmeldung(text);
107
 
        }
108
 
    }
109
 
 
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[]{});
113
 
    }
114
 
 
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});
117
 
    }
118
 
 
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[]{});
 
99
    }
 
100
 
 
101
    public static synchronized void fehlerMeldung(int fehlerNummer, String klasse, Exception ex, String text) {
 
102
        fehlermeldung_(fehlerNummer, klasse, ex, new String[]{text});
 
103
    }
 
104
 
 
105
    public static synchronized void fehlerMeldung(int fehlerNummer, String klasse, Exception ex, String text[]) {
 
106
        fehlermeldung_(fehlerNummer, klasse, ex, text);
121
107
    }
122
108
 
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});
126
112
    }
127
113
 
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);
130
116
    }
131
117
 
132
118
    public static synchronized void systemMeldung(String[] text) {
172
158
        systemMeldung("###########################################################");
173
159
    }
174
160
 
175
 
    public static void printFehlerMeldung() {
 
161
    private static void printFehlerMeldung() {
176
162
        systemMeldung("");
177
163
        systemMeldung("###########################################################");
178
164
        if (fehlerListe.size() == 0) {
183
169
            int i_2;
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) {
189
175
                    if (i_1 < i_2) {
190
176
                        fehlerListe.add(k - 1, fehlerListe.remove(k));
194
180
                }
195
181
            }
196
182
            for (Integer[] integers : fehlerListe) {
197
 
                String z;
198
 
                switch (integers[0]) {
199
 
                    case FEHLER_ART_MREADER:
200
 
                        z = FEHLER_ART_MREADER_TEXT;
201
 
                        break;
202
 
                    case FEHLER_ART_FILME_SUCHEN:
203
 
                        z = FEHLER_ART_FILME_SUCHEN_TEXT;
204
 
                        break;
205
 
                    case FEHLER_ART_GETURL:
206
 
                        z = FEHLER_ART_GETURL_TEXT;
207
 
                        break;
208
 
                    case FEHLER_ART_PROG:
209
 
                        z = FEHLER_ART_PROG_TEXT;
210
 
                        break;
211
 
                    case FEHLER_ART_NOGUI:
212
 
                        z = FEHLER_ART_NOGUI_TEXT;
213
 
                        break;
214
 
                    case FEHLER_ART_AUTO:
215
 
                        z = FEHLER_ART_AUTO_TEXT;
216
 
                        break;
217
 
                    default:
218
 
                        z = "";
219
 
                }
220
 
                boolean ex = integers[3] == 1;
 
183
                boolean ex = integers[2] == 1;
221
184
                String strEx;
222
185
                if (ex) {
223
186
                    strEx = "Ex! ";
224
187
                } else {
225
188
                    strEx = "    ";
226
189
                }
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]);
229
192
                } else {
230
 
                    systemMeldung(strEx + z + " Fehlernummer:  " + integers[1] + " Anzahl: " + integers[2]);
 
193
                    systemMeldung(strEx + " Fehlernummer:  " + integers[0] + " Anzahl: " + integers[1]);
231
194
                }
232
195
            }
233
196
        }
246
209
            int i_2;
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) {
252
215
                    if (i_1 < i_2) {
253
216
                        fehlerListe.add(k - 1, fehlerListe.remove(k));
257
220
                }
258
221
            }
259
222
            for (Integer[] integers : fehlerListe) {
260
 
                String z;
261
 
                switch (integers[0]) {
262
 
                    case FEHLER_ART_MREADER:
263
 
                        z = FEHLER_ART_MREADER_TEXT;
264
 
                        break;
265
 
                    case FEHLER_ART_FILME_SUCHEN:
266
 
                        z = FEHLER_ART_FILME_SUCHEN_TEXT;
267
 
                        break;
268
 
                    case FEHLER_ART_GETURL:
269
 
                        z = FEHLER_ART_GETURL_TEXT;
270
 
                        break;
271
 
                    case FEHLER_ART_PROG:
272
 
                        z = FEHLER_ART_PROG_TEXT;
273
 
                        break;
274
 
                    case FEHLER_ART_NOGUI:
275
 
                        z = FEHLER_ART_NOGUI_TEXT;
276
 
                        break;
277
 
                    case FEHLER_ART_AUTO:
278
 
                        z = FEHLER_ART_AUTO_TEXT;
279
 
                        break;
280
 
                    default:
281
 
                        z = "";
282
 
                }
283
 
                boolean ex = integers[3] == 1;
 
223
                boolean ex = integers[2] == 1;
284
224
                String strEx;
285
225
                if (ex) {
286
226
                    strEx = "Ex! ";
287
227
                } else {
288
228
                    strEx = "    ";
289
229
                }
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";
292
232
                } else {
293
 
                    ret += strEx + z + " Fehlernummer:  " + integers[1] + " Anzahl: " + integers[2] + "\n";
 
233
                    ret += strEx + " Fehlernummer:  " + integers[0] + " Anzahl: " + integers[1] + "\n";
294
234
                }
295
235
            }
296
236
        }
299
239
        return ret;
300
240
    }
301
241
 
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();
307
 
            if (i[1] == nr) {
308
 
                i[0] = art;
309
 
                i[2]++;
310
 
                i[3] = ex;
 
247
            if (i[0] == nr) {
 
248
                i[1]++;
 
249
                i[2] = ex;
311
250
                return;
312
251
            }
313
252
        }
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});
316
255
    }
317
256
 
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) {
321
260
            try {
322
261
                String s = getStackTrace(ex);
335
274
            } else {
336
275
                x = "=";
337
276
            }
338
 
            switch (art) {
339
 
                case FEHLER_ART_MREADER:
340
 
                    z = "  ==>";
341
 
                    break;
342
 
                case FEHLER_ART_FILME_SUCHEN:
343
 
                    z = "   >>";
344
 
                    break;
345
 
                case FEHLER_ART_GETURL:
346
 
                    z = "  ++>";
347
 
                    break;
348
 
                case FEHLER_ART_PROG:
349
 
                case FEHLER_ART_NOGUI:
350
 
                case FEHLER_ART_AUTO:
351
 
                default:
352
 
                    z = "*";
353
 
            }
 
277
            z = "*";
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());
358
282
            }
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);
364
288
            }
365
289
            System.out.println("");
366
290
            if (progress) {
369
293
        }
370
294
    }
371
295
 
372
 
    private static void debugmeldung(String texte) {
373
 
        if (progress) {
374
 
            // dann brauchen wir erst eine Leerzeite um die Progresszeile zu löschen
375
 
            System.out.print("                                                                            \r");
376
 
        }
377
 
        System.out.println("|||| " + texte);
378
 
        if (progress) {
379
 
            System.out.print(progressText);
380
 
        }
381
 
    }
382
 
 
383
296
    private static void systemmeldung(String[] texte) {
384
297
        if (progress) {
385
298
            // dann brauchen wir erst eine Leerzeite um die Progresszeile zu löschen
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]);
392
305
        } else {
393
306
            String zeile = "---------------------------------------";
394
307
            String txt;
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);
400
313
                if (i == 0) {
401
 
                    notifyMediathekListener(LOG_SYSTEM, texte[i]);
 
314
                    notifyPanelMeldung(LOG_SYSTEM, texte[i]);
402
315
                } else {
403
 
                    notifyMediathekListener(LOG_SYSTEM, "    " + texte[i]);
 
316
                    notifyPanelMeldung(LOG_SYSTEM, "    " + texte[i]);
404
317
                }
405
318
            }
406
 
            notifyMediathekListener(LOG_SYSTEM, " ");
 
319
            notifyPanelMeldung(LOG_SYSTEM, " ");
407
320
            System.out.println(z + zeile);
408
321
        }
409
322
        if (progress) {
418
331
        }
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]);
425
338
        }
426
339
        if (progress) {
427
340
            System.out.print(progressText);
439
352
            zeilenNrProgramm = 0;
440
353
            textProgramm.setLength(0);
441
354
        }
442
 
        ListenerMediathekView.notify(art, Log.class.getName());
443
355
    }
444
356
 
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);
452
364
        }
453
 
        ListenerMediathekView.notify(art, Log.class.getName());
 
365
        notifyPanel(art);
 
366
    }
 
367
 
 
368
    private static void notifyPanel(int art) {
 
369
        final int a = art;
 
370
        try {
 
371
            if (SwingUtilities.isEventDispatchThread()) {
 
372
                // notify
 
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();
 
379
                }
 
380
            } else {
 
381
                SwingUtilities.invokeLater(new Runnable() {
 
382
                    @Override
 
383
                    public void run() {
 
384
                        // notify
 
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();
 
391
                        }
 
392
                    }
 
393
                });
 
394
            }
 
395
        } catch (Exception ex) {
 
396
            Log.fehlerMeldung(698989743, "ListenerMediathekView.pingen", ex);
 
397
        }
454
398
    }
455
399
 
456
400
    private static String getStackTrace(Throwable t) {