LOGMINLEVEL: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 44: | Line 44: | ||
{{PageExamples}} | {{PageExamples}} | ||
; Example 1 : | ; Example 1: Avoid writing expensive log messages (e.g. [[_LOGTRACE]]) when the minimum logging level is set to Information (level 2). | ||
{{CodeStart}} | {{CodeStart}} | ||
level& = {{Cl|_LOGMINLEVEL}} | level& = {{Cl|_LOGMINLEVEL}} |
Latest revision as of 11:13, 30 May 2025
The _LOGMINLEVEL function returns the current minimum logging level that is being output.
Syntax
- level& = _LOGMINLEVEL
Parameters
- The return value level& is a number from 1 to 5 indicating the current minimum level of logging enabled. The below table indicates the mapping:
┌────────┬─────────────┐ │ Number │ Log level │ ├────────┼─────────────┤ │ 1 │ Trace │ ├────────┼─────────────┤ │ 2 │ Information │ ├────────┼─────────────┤ │ 3 │ Warning │ ├────────┼─────────────┤ │ 4 │ Error │ ├────────┼─────────────┤ │ 5 │ None │ └────────┴─────────────┘
Description
- The purpose of _LOGMINLEVEL is to allow programs to skip generating expensive logging if that logging would not be output anywhere.
- For example, you may have a very large array of integers that you want to log fairly often - generating the strings of the log messages for that array can slow down your program even if those messages are ultimately never written anywhere. By checking _LOGMINLEVEL before generating those log messages you can avoid that expensive work if it would not be used but also still produce it when you request it.
- If the function returns a 2, that indicates that only logging at the Information level and above (i.e. levels 3-4) is being captured somewhere. If the function returns a 5, that means no logging is being captured anywhere.
Availability
-
none
-
v4.0.0
-
yes
-
yes
-
yes
Examples
- Example 1
- Avoid writing expensive log messages (e.g. _LOGTRACE) when the minimum logging level is set to Information (level 2).
level& = _LOGMINLEVEL IF level& < 2 THEN ' Generate expensive log messages _LOGTRACE expensiveLogMessage$ END IF END |
See also