swift print doesn't appear in STDOut but 3rd party c library logs do when running in docker on ECS
Had the same issue, I filed a radar, and Apple answered:
When piped to another process print is buffered, so no characters appear until the buffer is filled up. (When piped to the terminal we only buffer until we hit a newline.)
You can get the behavior you want by calling
setbuf(stdout, nil)
once at startup:
import Darwin
setbuf(stdout, nil)
Swift: Extending functionality of print() function
You can overshadow the print
method from the standard library:
public func print(items: Any..., separator: String = " ", terminator: String = "\n") {
let output = items.map { "*\($0)" }.joined(separator: separator)
Swift.print(output, terminator: terminator)
}
Since the original function is in the standard library, its fully qualified name is Swift.print
Related Topics
What Is This Syntax: Func Funcname(Stuff1)(Stuff2)->Returntype {}
Delete Tableview Cell, and Remove Data from Firebase
How to Constrain 'self' to a Generic Type
Avspeechsynthesizer Isspeaking Not Working in Swift
Extract Reality Composer Scene for Arquicklook
Swift Set UIbutton Setbordercolor in Storyboard
Swift Janus Can Not Publish Video, But Get Remote Video Successful - Can Not Know Reason
Index or Range of Second Ocurence of Bytes in File
Cannot Convert Value of Type 'Foo!' to Expected Argument Type 'Foo!'
Scenekit Ar Game Fps Getting Low and The Device Getting Hot with Use
Shortest Code to Create an Array of Random Numbers in Swift
How to Modify Codable Class Properties
Writing an Enum Case Check to a Bool Variable Without Equatable Conformance
Swift Google Maps Smoothly Rounded Polylines
Apple's Swift Compiler Complains of Partial Application When Creating Extension Method on Array
How to Stretch a View to Its Parent Frame with Swiftui
Occasional Blank Frames After Exporting Asset - Avexportsession