github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/pkg/firecracker/client/models/logger.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "encoding/json" 10 11 strfmt "github.com/go-openapi/strfmt" 12 13 "github.com/go-openapi/errors" 14 "github.com/go-openapi/swag" 15 "github.com/go-openapi/validate" 16 ) 17 18 // Logger Describes the configuration option for the logging capability. 19 // swagger:model Logger 20 type Logger struct { 21 22 // Set the level. 23 // Enum: [Error Warning Info Debug] 24 Level *string `json:"level,omitempty"` 25 26 // The named pipe for the human readable log output. 27 // Required: true 28 LogFifo *string `json:"log_fifo"` 29 30 // The named pipe where the JSON-formatted metrics will be flushed. 31 // Required: true 32 MetricsFifo *string `json:"metrics_fifo"` 33 34 // Whether or not to output the level in the logs. 35 ShowLevel *bool `json:"show_level,omitempty"` 36 37 // Whether or not to include the file path and line number of the log's origin. 38 ShowLogOrigin *bool `json:"show_log_origin,omitempty"` 39 } 40 41 // Validate validates this logger 42 func (m *Logger) Validate(formats strfmt.Registry) error { 43 var res []error 44 45 if err := m.validateLevel(formats); err != nil { 46 res = append(res, err) 47 } 48 49 if err := m.validateLogFifo(formats); err != nil { 50 res = append(res, err) 51 } 52 53 if err := m.validateMetricsFifo(formats); err != nil { 54 res = append(res, err) 55 } 56 57 if len(res) > 0 { 58 return errors.CompositeValidationError(res...) 59 } 60 return nil 61 } 62 63 var loggerTypeLevelPropEnum []interface{} 64 65 func init() { 66 var res []string 67 if err := json.Unmarshal([]byte(`["Error","Warning","Info","Debug"]`), &res); err != nil { 68 panic(err) 69 } 70 for _, v := range res { 71 loggerTypeLevelPropEnum = append(loggerTypeLevelPropEnum, v) 72 } 73 } 74 75 const ( 76 77 // LoggerLevelError captures enum value "Error" 78 LoggerLevelError string = "Error" 79 80 // LoggerLevelWarning captures enum value "Warning" 81 LoggerLevelWarning string = "Warning" 82 83 // LoggerLevelInfo captures enum value "Info" 84 LoggerLevelInfo string = "Info" 85 86 // LoggerLevelDebug captures enum value "Debug" 87 LoggerLevelDebug string = "Debug" 88 ) 89 90 // prop value enum 91 func (m *Logger) validateLevelEnum(path, location string, value string) error { 92 if err := validate.Enum(path, location, value, loggerTypeLevelPropEnum); err != nil { 93 return err 94 } 95 return nil 96 } 97 98 func (m *Logger) validateLevel(formats strfmt.Registry) error { 99 100 if swag.IsZero(m.Level) { // not required 101 return nil 102 } 103 104 // value enum 105 if err := m.validateLevelEnum("level", "body", *m.Level); err != nil { 106 return err 107 } 108 109 return nil 110 } 111 112 func (m *Logger) validateLogFifo(formats strfmt.Registry) error { 113 114 if err := validate.Required("log_fifo", "body", m.LogFifo); err != nil { 115 return err 116 } 117 118 return nil 119 } 120 121 func (m *Logger) validateMetricsFifo(formats strfmt.Registry) error { 122 123 if err := validate.Required("metrics_fifo", "body", m.MetricsFifo); err != nil { 124 return err 125 } 126 127 return nil 128 } 129 130 // MarshalBinary interface implementation 131 func (m *Logger) MarshalBinary() ([]byte, error) { 132 if m == nil { 133 return nil, nil 134 } 135 return swag.WriteJSON(m) 136 } 137 138 // UnmarshalBinary interface implementation 139 func (m *Logger) UnmarshalBinary(b []byte) error { 140 var res Logger 141 if err := swag.ReadJSON(b, &res); err != nil { 142 return err 143 } 144 *m = res 145 return nil 146 }