@@ -15,44 +15,44 @@ extension PinLayoutImpl {
1515
1616 internal func relativeEdgeContext( method: String , edge: VerticalEdge ) -> String {
1717 let edge = edge as! VerticalEdgeImpl
18- return " \( method) (to: \( edge. type. rawValue) , of: \( edge. view) ) "
18+ return " \( method) (to: . \( edge. type. rawValue) , of: \( viewDescription ( edge. view) ) ) "
1919 }
2020
2121 internal func relativeEdgeContext( method: String , edge: HorizontalEdge ) -> String {
2222 let edge = edge as! HorizontalEdgeImpl
23- return " \( method) (to: \( edge. type. rawValue) , of: \( edge. view) ) "
23+ return " \( method) (to: . \( edge. type. rawValue) , of: \( viewDescription ( edge. view) ) "
2424 }
2525
2626 internal func relativeAnchorContext( method: String , anchor: Anchor ) -> String {
2727 let anchor = anchor as! AnchorImpl
28- return " \( method) (to: \( anchor. type. rawValue) , of: \( anchor. view) ) "
28+ return " \( method) (to: . \( anchor. type. rawValue) , of: \( viewDescription ( anchor. view) ) ) "
2929 }
3030
3131 internal func warn( _ text: String , _ context: Context ) {
3232 guard Pin . logWarnings else { return }
33- warn ( " \( context ( ) ) won't be applied, \( text) \n " )
33+ warn ( " \( context ( ) ) won't be applied, \( text) " )
3434 }
3535
3636 internal func warn( _ text: String ) {
3737 guard Pin . logWarnings else { return }
38- displayWarning ( " \n 👉 PinLayout Warning: \( text) \n " )
38+ displayWarning ( " PinLayout Warning: \( text) " )
3939 }
4040
4141 internal func warnPropertyAlreadySet( _ propertyName: String , propertyValue: CGFloat , _ context: Context ) {
4242 guard Pin . logWarnings else { return }
43- displayWarning ( " \n 👉 PinLayout Conflict: \( context ( ) ) won't be applied since it value has already been set to \( propertyValue) . \n " )
43+ displayWarning ( " PinLayout Conflict: \( context ( ) ) won't be applied since it value has already been set to \( propertyValue) . " )
4444 }
4545
4646 internal func warnPropertyAlreadySet( _ propertyName: String , propertyValue: CGSize , _ context: Context ) {
4747 guard Pin . logWarnings else { return }
48- displayWarning ( " \n 👉 PinLayout Conflict: \( context ( ) ) won't be applied since it value has already been set to CGSize(width: \( propertyValue. width) , height: \( propertyValue. height) ). \n " )
48+ displayWarning ( " PinLayout Conflict: \( context ( ) ) won't be applied since it value has already been set to CGSize(width: \( propertyValue. width) , height: \( propertyValue. height) ). " )
4949 }
5050
5151 internal func warnConflict( _ context: Context , _ properties: [ String : CGFloat ] ) {
5252 guard Pin . logWarnings else { return }
53- var warning = " \n 👉 PinLayout Conflict: \( context ( ) ) won't be applied since it conflicts with the following already set properties: \n "
53+ var warning = " PinLayout Conflict: \( context ( ) ) won't be applied since it conflicts with the following already set properties: "
5454 properties. forEach { ( property) in
55- warning += " \( property. key) : \( property. value) \n "
55+ warning += " \n \( property. key) : \( property. value) "
5656 }
5757
5858 displayWarning ( warning)
@@ -83,12 +83,31 @@ extension PinLayoutImpl {
8383 }
8484
8585 internal func displayWarning( _ text: String ) {
86- print ( text)
86+ var displayText = " \n 👉 \( text) "
87+ displayText += " \n (Layouted view info: Type: \( viewName ( view) ) , Frame: \( view. frame) "
88+
89+ var currentView = view
90+ var hierarchy : [ String ] = [ ]
91+ while let parent = currentView. superview {
92+ hierarchy. insert ( " \( type ( of: parent) ) " , at: 0 )
93+ currentView = parent
94+ }
95+ if hierarchy. count > 0 {
96+ displayText += " , Superviews: \( hierarchy. flatMap ( { $0 } ) . joined ( separator: " -> " ) ) "
97+ }
98+
99+ displayText += " , Tag: \( view. tag) ) \n "
100+
101+ print ( displayText)
87102 _pinlayoutUnitTestLastWarning = text
88103 }
89104
90105 internal func viewDescription( _ view: UIView ) -> String {
91- return " \" \( view. description) \" "
106+ return " ( \( viewName ( view) ) , Frame: \( view. frame) ) "
107+ }
108+
109+ internal func viewName( _ view: UIView ) -> String {
110+ return " \( type ( of: view) ) "
92111 }
93112}
94113
0 commit comments