DiagnosticLevel ( index )
Parameters
| index - record to read, from 1 (oldest) through CountDiagnostics() |
Description
|
Returns a diagnostic record's severity: 1 information, 2 warning, 3 error. The level is how you triage the store. A quick loop over 1 through CountDiagnostics() that only reacts to level 3 gives you an "anything actually broken?" check to run after loading a level's assets; level 2 warnings (a skipped decal, an unsupported blend mode) are worth logging; level 1 records are confirmations like a successful texture reload. The values: 1: information - something worked or is worth knowing 2: warning - something was off, but the engine carried on 3: error - something failed, such as a load that returned nothing An index below 1 or above CountDiagnostics() stops the program with a runtime error, so read the count first. Requires Extended mode. See also: CountDiagnostics, DiagnosticCategory, DiagnosticMessage, DiagnosticSource. |
Example
; DiagnosticLevel Example ; ----------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-6 light=CreateLight() RotateEntity light,45,45,0 pad=CreateCylinder() ScaleEntity pad,1.5,0.1,1.5 EntityColor pad,80,200,255 ; Two failed asset loads seed the diagnostic store with records to browse enemy=LoadMesh("enemy_model.glb") powerup=LoadMesh("powerup_model.glb") index=1 While Not KeyDown(1) ; Space adds another failure, [ and ] browse the records If KeyHit(57) Then crate=LoadMesh("crate_model.glb") If KeyHit(26) And index>1 Then index=index-1 If KeyHit(27) And index<CountDiagnostics() Then index=index+1 TurnEntity pad,0,1,0 ; DiagnosticLevel returns 1 information, 2 warning or 3 error level=DiagnosticLevel(index) If level=1 Then label$="information" If level=2 Then label$="warning" If level=3 Then label$="error" ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"[ / ] : browse records Space: add failure Arrows: camera Esc: exit" Text 0,20,"Record "+index+" of "+CountDiagnostics() Text 0,40,"DiagnosticLevel("+index+") = "+level+" ("+label+")" Flip Wend End
Index