about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2024-01-12 18:51:01 +0100
committerLeah Neukirchen <leah@vuxu.org>2024-01-12 18:51:01 +0100
commit5cc099eb8e2160a69217b5d117b94d5ab73f7620 (patch)
treeeb7f60a505883f3484b3486d30edcbbeabb862bb
parent6c63029ea6937b25e6128ebe330d2b760cac9160 (diff)
downloadmlog-5cc099eb8e2160a69217b5d117b94d5ab73f7620.tar.gz
mlog-5cc099eb8e2160a69217b5d117b94d5ab73f7620.tar.xz
mlog-5cc099eb8e2160a69217b5d117b94d5ab73f7620.zip
also detect svlogd -t and svlogd -tt timestamps v0.1
-rw-r--r--mlog.c64
1 files changed, 36 insertions, 28 deletions
diff --git a/mlog.c b/mlog.c
index 0f2ba72..4167555 100644
--- a/mlog.c
+++ b/mlog.c
@@ -105,36 +105,44 @@ strip(int i)
 	char *s = logs[i].line;
 	char *z = s + logs[i].linelen;
 
-	int d = 0;
-	int m = 0;
-	int t = 0;
-	int c = 0;
-	int p = 0;
-	int e = 0;
-
-	while (s < z && *s != ' ') {
-		switch (*s++) {
-		case '-': m++; break;
-		case 'T': t++; break;
-		case ':': c++; break;
-		case '.': p++; break;
-		case '0':
-		case '1':
-		case '2':
-		case '3':
-		case '4':
-		case '5':
-		case '6':
-		case '7':
-		case '8':
-		case '9': d++; break;
-		default: e++;
+	if ('0' <= s[0] && s[0] <= '9') { /* ISO */
+		int d = 0, m= 0, t = 0, c = 0, p = 0, e = 0;
+
+		// 2024-01-10T17:57:34.40282
+		// 2024-01-10_17:57:34.40282
+		while (s < z && *s != ' ') {
+			switch (*s++) {
+			case '-': m++; break;
+			case '_':
+			case 'T': t++; break;
+			case ':': c++; break;
+			case '.': p++; break;
+			case '0':
+			case '1':
+			case '2':
+			case '3':
+			case '4':
+			case '5':
+			case '6':
+			case '7':
+			case '8':
+			case '9': d++; break;
+			default: e++;
+			}
 		}
-	}
-
-	// 2024-01-10T17:57:34.40282
-	if (!(d == 19 && m == 2 && t == 1 && c == 2 && e == 0))
+		if (!(e == 0 && d == 19 && m == 2 && t == 1 && c == 2))
+			return;
+	} else if (s[0] == '@') { /* hex TAI */
+		// @4000000065a07a8e011726e4
+		size_t h = 0;
+		while (++s < z && *s != ' ')
+			if ((unsigned)*s-'0' < 10 || ((unsigned)*s|32)-'a' < 6)
+				h++;
+		if (h != 24)
+			return;
+	} else {
 		return;
+	}
 
 	char *b = s;