class Logging { private readonly ParentElement : HTMLElement ; private readonly ChildElementType : string ; constructor ( parentElement , childElementType ) { this . ParentElement = parentElement ; this . ChildElementType = childElementType ; } public Log ( message ) { let dateTime = new Date ( ) ; let lineText = "[" + ( dateTime . getHours ( ) > 9 ? dateTime . getHours ( ) : "0" + dateTime . getHours ( ) ) + ":" + ( dateTime . getMinutes ( ) > 9 ? dateTime . getMinutes ( ) : "0" + dateTime . getMinutes ( ) ) + ":" + ( dateTime . getSeconds ( ) > 9 ? dateTime . getSeconds ( ) : "0" + dateTime . getSeconds ( ) ) + "] " + message ; if ( this . ParentElement && this . ChildElementType ) { let line = document . createElement ( this . ChildElementType ) ; line . innerText = lineText ; this . ParentElement . appendChild ( line ) ; } else { console . log ( lineText ) ; } } }