Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

ShowLog

ShowLog( <cTexto> )

Displays text in a log window, useful for visually inspecting queries, messages and support information during tests.

AdvPL functionsInterfaceDebuggingLogSQLUnder review
01 · OVERVIEW

Overview

ShowLog is often used in AdvPL routines to present long text or diagnostic data in a log window. In practice, it is commonly applied during development and staging to view dynamically built SQL queries, variable contents or support messages. For safety and organization, restrict its use to administrative profiles and avoid showing it to final users in production.

02 · SYNTAX

Syntax

ShowLog( <cTexto> )

Parameters

cTexto
CaractereRequired

Text displayed in the log window. It may contain a query, a technical message or other content used to support analysis.

Return value

The reference used does not document a return value for ShowLog. Use it for information display, not as part of a decision rule.

03 · PRACTICAL EXAMPLE

Display a query only for administrators

#Include "TOTVS.ch"

User Function ShowQuery()
    Local cQuery := ""

    cQuery := " SELECT * "
    cQuery += " FROM " + RetSQLName("SBM") + " SBM "
    cQuery += " WHERE BM_FILIAL = '" + FWxFilial("SBM") + "' "
    cQuery += " AND SBM.D_E_L_E_T_ = ' ' "

    If FWIsAdmin()
        ShowLog(cQuery)
    EndIf
Return
Expected result

When the user is an administrator, the generated query is displayed in a log window for visual checking.

04 · PRACTICAL EXAMPLE

Create a helper function to view queries

#Include "TOTVS.ch"

User Function ViewQuery(cQuery)
    Default cQuery := ""

    If ! IsBlind() .And. ! Empty(cQuery) .And. FWIsAdmin()
        If FWAlertYesNo("Do you want to view the query?", "Attention (" + FunName() + ")")
            ShowLog(cQuery)
        EndIf
    EndIf
Return
Expected result

The helper centralizes checks: it does not run in non-interactive mode, ignores empty text, restricts access to administrators and asks for confirmation before opening the log.

BEST PRACTICES
  • Use ShowLog as a support tool in development, staging or controlled diagnostics.
  • When displaying SQL queries, restrict usage to administrators with FWIsAdmin().
  • Avoid showing sensitive data, tokens, passwords, keys or personal information in visible logs.
  • In automatic routines or non-interactive execution, validate the context before opening windows.
  • For more controlled title, scroll bar and confirmation options, evaluate AtShowLog when available in the environment.
COMMON PITFALLS
  • Showing ShowLog to any user may expose technical details or sensitive information.
  • Leaving visual logs in production may interrupt the routine flow and confuse final users.
  • A query displayed on screen may reveal table names, filters, aliases and internal system rules.
  • Do not use ShowLog as a substitute for structured logs when technical history must be stored.

Related content

REFERENCES
  1. ATILIO, Daniel. How to use the ShowLog function. Terminal de Informação, Dec. 22, 2021; update mentioned in Dec. 2022.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha