From 51509e3b212d6aeae8c946beb454e0ed74e048c7 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 4 Nov 2018 15:16:28 +0100 Subject: Add `teprintf()` function A new function to print to stderr prefixed with a timestamp. The idea is to make the printed line's format match the Rust logger's. The Rust logger prints timestamps like this: 2018-11-04T03:16:31.938+01:00 `teprintf` does: 2018-11-04T15:02:21+0100 Unfortunately, I wasn't able to reproduce it exactly. It's missing the milliseconds because I didn't want to deal with using `gettimeofday`, and the time zone format isn't right because I didn't know how to format it easily with a colon. Resources: Getting the time in C: https://stackoverflow.com/questions/9596945/how-to-get-appropriate-timestamp-in-c-for-logs#9596994 Variadic functions in C: https://stackoverflow.com/questions/205529/passing-variable-number-of-arguments-around Getting milliseconds in C: https://stackoverflow.com/questions/10192903/time-in-milliseconds#10192994 https://stackoverflow.com/questions/3673226/how-to-print-time-in-format-2009-08-10-181754-811 https://stackoverflow.com/questions/361363/how-to-measure-time-in-milliseconds-using-ansi-c Concatenating strings in C: https://stackoverflow.com/questions/308695/how-do-i-concatenate-const-literal-strings-in-c#308712 https://stackoverflow.com/questions/8465006/how-do-i-concatenate-two-strings-in-c --- DomeKey.xcodeproj/project.pbxproj | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'DomeKey.xcodeproj') diff --git a/DomeKey.xcodeproj/project.pbxproj b/DomeKey.xcodeproj/project.pbxproj index 3da05f9..110ee5b 100644 --- a/DomeKey.xcodeproj/project.pbxproj +++ b/DomeKey.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ D110C94A2122F1ED0094F963 /* libddhid.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D160C32221197983007D1B50 /* libddhid.a */; }; D11184622125206E00961687 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D11184612125206E00961687 /* AppDelegate.m */; }; D11CD06D217FECD9001FCB97 /* AquaticPrime.c in Sources */ = {isa = PBXBuildFile; fileRef = D11CD067217FECD9001FCB97 /* AquaticPrime.c */; }; + D12B5B76218F31E300C6F7FC /* log.c in Sources */ = {isa = PBXBuildFile; fileRef = D12B5B71218F31E200C6F7FC /* log.c */; }; D131C4D321663B6500801267 /* Mappings.m in Sources */ = {isa = PBXBuildFile; fileRef = D131C4D221663B6500801267 /* Mappings.m */; }; D160C2A12118EF9D007D1B50 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D160C2A02118EF9D007D1B50 /* main.m */; }; D18255B12180018C00ABC1E0 /* LicenseHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = D18255B02180018C00ABC1E0 /* LicenseHandler.m */; }; @@ -77,6 +78,7 @@ D11184612125206E00961687 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; D11CD067217FECD9001FCB97 /* AquaticPrime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = AquaticPrime.c; path = lib/AquaticPrime/Source/CoreFoundation/AquaticPrime.c; sourceTree = SOURCE_ROOT; }; D11CD06C217FECD9001FCB97 /* AquaticPrime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AquaticPrime.h; path = lib/AquaticPrime/Source/CoreFoundation/AquaticPrime.h; sourceTree = SOURCE_ROOT; }; + D12B5B71218F31E200C6F7FC /* log.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = log.c; sourceTree = ""; }; D131C4D121663B6500801267 /* Mappings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Mappings.h; sourceTree = ""; }; D131C4D221663B6500801267 /* Mappings.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Mappings.m; sourceTree = ""; }; D160C29D2118EF9D007D1B50 /* DomeKey */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DomeKey; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -141,6 +143,7 @@ D18255B02180018C00ABC1E0 /* LicenseHandler.m */, D1EAA7A221803BB300A0AC35 /* XDG.h */, D1EAA7A321803BB300A0AC35 /* XDG.m */, + D12B5B71218F31E200C6F7FC /* log.c */, ); path = DomeKey; sourceTree = ""; @@ -273,6 +276,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + D12B5B76218F31E300C6F7FC /* log.c in Sources */, D131C4D321663B6500801267 /* Mappings.m in Sources */, D1EAA7A421803BB300A0AC35 /* XDG.m in Sources */, D1C80CA021877E8200011088 /* Sounds.m in Sources */, -- cgit v1.2.3