anz-bank / sysl-go

Communication library used by SYSL-generated code written in Go.
Apache License 2.0
10 stars 14 forks source link

I would like to be able to add logging in the generated Golang code #227

Open john-isa opened 2 years ago

john-isa commented 2 years ago

Purpose

I would like to be able to set up logging in the sysl-generated code so as to:

Suggested approaches

An Example

import upstream.yaml as UP ~openapi3    ## logs endpoint entry (headers and body) and response (headers and body)
import downstream.yaml as DOWN [~log]   ## logs endpoint entry (headers and body) and response (headers and body)

UP [~validate]: 
    @package="UP"

    /dotheup: [~log] 
        POST:
            DOWN <- POST /do/the/down [~log] 
            | DOWN forwards the request asynchronously and replies immediately

    !type HealthCheckResponse:                ## logs all variables of this type
        Status <: string
        ServiceName <: string
        AppVersion <: string

    !type MissingParameter [~error]:          ## logs all variables of this type
        http_status <: string [value = "400"]
        http_message <: string [value = "Missing one or more of the required parameters"]

    !type CustomInternalServerError [~error]: ## logs all variables of this type
        http_status <: string [value = "500"]
        http_message <: string [value = "Internal Server Error"]

Also is it possible to put in a specially formatted comment in the yaml files to allow fine-grain control of what to log?