summaryrefslogtreecommitdiff
path: root/dslog/Main.java
blob: 5fa053383acdd67da1f825ff6c0fbcd877f04b19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package dslog;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedMap;
import java.util.Map;
import java.util.TreeMap;

class Main {
	public static void dslog2csv(String filename) throws IOException {
		try (DslogReader file = new DslogReader(Files.newInputStream(Paths.get(filename)))) {
			System.out.println("Format Version: "+file.version());
			System.out.println("Start Time: "+file.startTime());
			CsvWriter.Dslog2CSV(file, System.out);
		}
	}

	public static void ls(String dirname) throws IOException {
		LogDir.opendir(dirname).forEach((k,v)->{
			System.out.println(v);
		});
	}

	public static void wch(String dirname) throws IOException {
		LogDir.opendir(dirname).forEach((k,v)->{
			boolean match = false;
			try (DseventsReader r = v.dsevents()) {
				if (r == null || r.version() != 3)
					return;
				while (r.hasNext()) {
					DseventsReader.Event e = r.next();
					System.out.println(e.time +"\u001E"+e.message);
				}
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		});
	}

	public static void main(String[] args) throws IOException {
		for (String dirname : args) {
			wch(dirname);
		}
	}
}