Skip to content

Refactor: Table driven compiler and variable logging.#2739

Open
trulede wants to merge 1 commit intogo-task:mainfrom
trulede:PR/refactor-compiler
Open

Refactor: Table driven compiler and variable logging.#2739
trulede wants to merge 1 commit intogo-task:mainfrom
trulede:PR/refactor-compiler

Conversation

@trulede
Copy link
Contributor

@trulede trulede commented Mar 11, 2026

For consideration.

A refactoring of the compiler to use a table driven approach, especially the getVariables() function and introduction of variable logging to assist in Taskfile debug. No functional change.

Additional?

  • Set the envar to the name of a variable to filter logging: TASK_DEBUG_COMPILER=FOO;BAR.
  • Structured logging - see PR Advanced logging with slog. #2617 .
  • Further changes relating to handling of DOTENV files (specifically relocating the merge code to the compiler).
  • Tests, once operation is refined.

Operation

Currently the logging is enabled by a "secret" environment variable and the -v flag. The intention is to integrate the debug into a more capable logging framework where a log category can be assigned (see PR #2617).

This logging is disabled by default because the output impacts some test fixtures ... and there is a lot of it!

Unchanged (by Task) environment variables are not printed by the logging, which reduces the volume of logs significantly, and avoids, but does not prevent, printing of sensitive data.

TASK_DEBUG_COMPILER=1 task -v -t testdata/compiler/debug_compiler/Taskfile.yml 2>&1 | less -R

Output ... there is a lot of it

FastGetVariables: task=default, call=default
  compiler: variable merge: OS.Env
  compiler: variable merge: SpecialVars
    TASK_EXE <-- task
    ROOT_DIR <-- /home/trule/git/task/testdata/compiler/debug_compiler
    USER_WORKING_DIR <-- /home/trule/git/task
    TASK_VERSION <-- 3.49.1
    TASK <-- default
    TASK_DIR <-- /home/trule/git/task/testdata/compiler/debug_compiler
    TASKFILE <-- /home/trule/git/task/testdata/compiler/debug_compiler/Taskfile.yml
    TASKFILE_DIR <-- /home/trule/git/task/testdata/compiler/debug_compiler
    ROOT_TASKFILE <-- /home/trule/git/task/testdata/compiler/debug_compiler/Taskfile.yml
    ALIAS <-- default
  compiler: variable merge: Taskfile.Env
    TASKFILE_ENV <-- taskfile_env
  compiler: variable merge: Taskfile.Vars
    CLI_ARGS <-- 
    CLI_ARGS_LIST <-- []
    CLI_FORCE <-- false
    CLI_SILENT <-- false
    CLI_VERBOSE <-- true
    CLI_OFFLINE <-- false
    CLI_ASSUME_YES <-- false
    TASKFILE_VAR <-- taskfile_var
  compiler: variable merge: Inc.Vars
  compiler: variable merge: IncTaskfile.Vars
  compiler: variable merge: Call.Vars
    MATCH <-- []
  compiler: variable merge: Task.Vars
    TASK_VAR <-- task_var
GetVariables: task=default, call=default
  compiler: variable merge: OS.Env
  compiler: variable merge: SpecialVars
    TASK_EXE <-- task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant