Hi Eskimo! Thanks for answering.
I was able to execute that command but every step I do I get lost again.
e.g:
swift
vagrants-iMac:~ rootswift
Welcome to Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51).
Type :help for assistance.
1 import OSLog
2 let store = try OSLogStore.local()
store: OSLogStore = {
baseNSObject@0 = {
isa = OSLogStore
}
_source = {
NSObject = {
isa = OSLogEventSource
}
_fileRefs = 89 elements
_lcr =
_lesm =
_oldestTimeRef =
_tsdb =
}
}
3 let myDate = Date().addingTimeInterval(-3600) /* time in secs (one hour) */
myDate: Date = {}
4 let oneHourAgo = store.position(date: myDate)
oneHourAgo: OSLogPosition = uninitialized
5 let myEntries = store.getEntries(at: oneHourAgo)
myEntries: AnySequenceOSLogEntry = {
_box = extracting data from value failed
}
error: Couldn't lookup symbols:
(extension in OSLog):__C.OSLogStore.getEntries(with: __C.OSLogEnumeratorOptions, at: Swift.Optional__C.OSLogPosition, matching: Swift.Optional__C.NSPredicate) throws - Swift.AnySequence__C.OSLogEntry
(extension in OSLog):__C.OSLogStore.getEntries(with: __C.OSLogEnumeratorOptions, at: Swift.Optional__C.OSLogPosition, matching: Swift.Optional__C.NSPredicate) throws - Swift.AnySequence__C.OSLogEntry
Is there any developer guide to get log entries? I couldn't find it...
In any case, if you can provide us with a very simple code to get a log it would be a great starting point for me and the rest of the community since I couldn't find any working example, and we all will be very grateful :) thanks in advance for any guidance you can provide me ^^
Post
Replies
Boosts
Views
Activity
Hi Eskimo, your help is much appreciated :)
I tried running the example code but I get segmentation faults and I am not sure why or how to solve it. Just copy-pasted it into a plain text file named "example.swift" and this is the command line output when I try to run it:
bash
vagrants-iMac:~ rootswift example.swift
Stack dump: Program arguments: /Library/Developer/CommandLineTools/usr/bin/swift -frontend -interpret example.swift -enable-objc-interop -stack-check -sdk /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -color-diagnostics -module-name example
Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51)
While running user code "example.swift"
0 swift 0x0000000106de54ea PrintStackTraceSignalHandler(void*) + 42
1 swift 0x0000000106de4cc0 SignalHandler(int) + 352
2 libsystem_platform.dylib 0x00007fff66536b1d _sigtramp + 29
3 libsystem_platform.dylib 0x00000001085c3000 _sigtramp + 2718483712
4 libsystem_platform.dylib 0x000000010ad8e013 _sigtramp + 2760209683
5 swift 0x0000000102b6848a llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRefllvm::GenericValue) + 458
6 swift 0x0000000102b6f4fb llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::__1::vectorstd::__1::basic_stringchar, std::__1::char_traitschar, std::__1::allocatorchar , std::__1::allocatorstd::__1::basic_stringchar, std::__1::char_traitschar, std::__1::allocatorchar const&, char const* const*) + 2011
7 swift 0x0000000102b445ba performCompileStepsPostSILGen(swift::CompilerInstance&, swift::CompilerInvocation&, std::__1::unique_ptrswift::SILModule, std::__1::default_deleteswift::SILModule , bool, llvm::PointerUnionswift::ModuleDecl*, swift::SourceFile*, swift::PrimarySpecificPaths const&, bool, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 14362
8 swift 0x0000000102b38f75 swift::performFrontend(llvm::ArrayRefchar const*, char const*, void*, swift::FrontendObserver*) + 55813
9 swift 0x0000000102aaef53 main + 1283
10 libdyld.dylib 0x00007fff66331c49 start + 1
Segmentation fault: 11
Do you have any clue on what can be causing trouble?
thanks in advance for your valuable help :)