000023725 - Debug output destination

Document created by RSA Customer Support Employee on Jun 16, 2016Last modified by RSA Customer Support Employee on Apr 21, 2017
Version 2Show Document
  • View in full screen mode

Article Content

Article Number000023725
Applies ToRKM Client 1.5.x
IssueSpecify output location for debug output
Config file has the debug output enabled but no debug output displays.

kms.debug = true
ResolutionThe RKM 1.5.x clients write their debug output to stdout.  This is the standard console output buffer.  For console applications this causes the debug output to display on the console.  For graphical applications stdout must be captured in order to see the debug output.  The simplest way to do this is to redirect stdout to a file.
NotesC code for redirecting stdout to a file:

 FILE* fErr = freopen ("kmcerr.log", "w", stderr);
 FILE*
fOut = freopen ("kmc.log", "w", stdout);
    if (
fOut)
       
setbuf (fOut, NULL);  // Disable write buffering
 else {
  status = -4;
  break;
 }
 if (
fErr)
 
setbuf (fErr, NULL);  // Disable write buffering
 else {
  status = -5;
  break;
 }

Visual Basic 6 code for opening a console to display stdout:

Private mIsConsoleAlloc As Boolean
Private mhConsoleOut As Long

Private Declare Function GetStdHandle Lib "kernel32" _
    (ByVal nStdHandle As Long) As Long

Private Declare Function WriteConsole Lib "kernel32" _
    Alias "WriteConsoleA" _
    (ByVal hConsoleOutput As Long, _
     ByVal lpBuffer As Any, _
     ByVal nNumberOfCharsToWrite As Long, _
     lpNumberOfCharsWritten As Long, _
     pReserved As Any) As Long

Private Declare Function AllocConsole Lib "kernel32" () As Long Private Declare Function FreeConsole Lib "kernel32" () As Boolean Private Declare Function GetConsoleWindow Lib "kernel32" () As Long

Private Sub setupConsole()
    Dim consoleHnd As Long

    ' Check for existing console
    consoleHnd = GetConsoleWindow()
    If consoleHnd = 0 Then
        ' Have to allocate a console
       
        If AllocConsole() = 0 Then
            Exit Sub
        End If
       
        mIsConsoleAlloc = True
        consoleHnd = GetConsoleWindow()
    End If
   
    Const STD_INPUT_HANDLE   As Long = -10
    Const STD_OUTPUT_HANDLE  As Long = -11
    Const STD_ERROR_HANDLE   As Long = -12
   
    If consoleHnd <> 0 Then
        mhConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE)
        ShowWindow consoleHnd, SW_NORMAL
    End If
End Sub


' Cleanup
'
'  Deallocates an alloc'd console
'
Sub Cleanup()
    If mIsConsoleAlloc Then
        Dim consoleHnd As Long
       
        consoleHnd = GetConsoleWindow()
        ShowWindow consoleHnd, SW_NORMAL
       
        mIsConsoleAlloc = False
    End If
   
    ' It is safe to always free this application from the current console.
    FreeConsole
End Sub

' WriteLine
'
'  Write the given line of text to the console '
'  Argument:
'   txt     - line of text to write to console
'
Sub WriteLine(txt As String)
    If mhConsoleOut = 0 Then
        Exit Sub
    End If
   
    WriteConsole mhConsoleOut, txt & vbCrLf, Len(txt) + 2, vbNull, vbNull End Sub

Legacy Article IDa37046

Attachments

    Outcomes