Skip to content

Make error messages format customizable to have standard parsable error logs #2090

Description

@soubinan

Enhancement

We are trying to use the error messages (from compilation, linting, validation and tests) to loop into another application input so this application could properly and natively show the kcl errors according to our needs by following our app logging standards.
But current kcl error message is formatted in a way it makes difficult to actually use it as is.
It would be great to be able to just have the error message in a standard format parsable by another app from stdout or stderr depending on the cases.

What we currently

error[E2F04]: CannotFindModule
 --> /workspaces/f5-tool/internal/kcl/lib.k:7:1
  |
7 | import kcl_plugin.as3_render as asr
  | ^ the plugin package `kcl_plugin.as3_render` is not found, please confirm if plugin mode is enabled
  |


error[E2L23]: CompileError
  --> /workspaces/f5-tool/internal/kcl/models/application.k:17:16
   |
17 |     monitors?: {str:Monitocr}
   |                ^ name 'Monitocr' is not defined, did you mean '["Monitor"]'?
   |

What we expect (as a plain text example)

/workspaces/f5-tool/internal/kcl/lib.k:7:1 - error[E2F04]: CannotFindModule - the plugin package `kcl_plugin.as3_render` is not found, please confirm if plugin mode is enabled

/workspaces/f5-tool/internal/kcl/models/application.k:17:16 - error[E2L23]: CompileError - name 'Monitocr' is not defined, did you mean '["Monitor"]'?

What we expect (as a arcanist json example)

[
  {
    "Char": 1,
    "Code": "error[E2F04]",
    "Description": "the plugin package `kcl_plugin.as3_render` is not found, please confirm if plugin mode is enabled",
    "Line": 7,
    "Name": "CannotFindModule",
    "OriginalText": "import kcl_plugin.as3_render as asr",
    "Path": "/workspaces/f5-tool/internal/kcl/lib.k"
  },
    {
    "Char": 16,
    "Code": "error[E2L23]",
    "Description": "name 'Monitocr' is not defined, did you mean '[\"Monitor\"]'?",
    "Line": 17,
    "Name": "CompileError",
    "OriginalText": "     monitors?: {str:Monitocr}",
    "Path": "/workspaces/f5-tool/internal/kcl/models/application.k"
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions