|
| 1 | +// Copyright The OpenTelemetry Authors |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +//go:generate stringer -type=Kind -trimprefix=Kind |
| 16 | + |
| 17 | +package log // import "go.opentelemetry.io/otel/log" |
| 18 | + |
| 19 | +// Kind is the kind of a [Value]. |
| 20 | +type Kind int |
| 21 | + |
| 22 | +// Kind values. |
| 23 | +const ( |
| 24 | + KindEmpty Kind = iota |
| 25 | + KindBool |
| 26 | + KindFloat64 |
| 27 | + KindInt64 |
| 28 | + KindString |
| 29 | + KindBytes |
| 30 | + KindList |
| 31 | + KindMap |
| 32 | +) |
| 33 | + |
| 34 | +// A Value represents a structured log value. |
| 35 | +type Value struct{} // TODO (#4914): implement. |
| 36 | + |
| 37 | +// StringValue returns a new [Value] for a string. |
| 38 | +func StringValue(v string) Value { return Value{} } // TODO (#4914): implement. |
| 39 | + |
| 40 | +// IntValue returns a [Value] for an int. |
| 41 | +func IntValue(v int) Value { return Value{} } // TODO (#4914): implement. |
| 42 | + |
| 43 | +// Int64Value returns a [Value] for an int64. |
| 44 | +func Int64Value(v int64) Value { return Value{} } // TODO (#4914): implement. |
| 45 | + |
| 46 | +// Float64Value returns a [Value] for a float64. |
| 47 | +func Float64Value(v float64) Value { return Value{} } // TODO (#4914): implement. |
| 48 | + |
| 49 | +// BoolValue returns a [Value] for a bool. |
| 50 | +func BoolValue(v bool) Value { //nolint:revive // Not a control flag. |
| 51 | + // TODO (#4914): implement. |
| 52 | + return Value{} |
| 53 | +} |
| 54 | + |
| 55 | +// BytesValue returns a [Value] for a byte slice. The passed slice must not be |
| 56 | +// changed after it is passed. |
| 57 | +func BytesValue(v []byte) Value { return Value{} } // TODO (#4914): implement. |
| 58 | + |
| 59 | +// ListValue returns a [Value] for a slice of [Value]. The passed slice must |
| 60 | +// not be changed after it is passed. |
| 61 | +func ListValue(vs ...Value) Value { return Value{} } // TODO (#4914): implement. |
| 62 | + |
| 63 | +// MapValue returns a new [Value] for a slice of key-value pairs. The passed |
| 64 | +// slice must not be changed after it is passed. |
| 65 | +func MapValue(kvs ...KeyValue) Value { return Value{} } // TODO (#4914): implement. |
| 66 | + |
| 67 | +// AsAny returns the value held by v as an any. |
| 68 | +func (v Value) AsAny() any { return nil } // TODO (#4914): implement |
| 69 | + |
| 70 | +// AsString returns the value held by v as a string. |
| 71 | +func (v Value) AsString() string { return "" } // TODO (#4914): implement |
| 72 | + |
| 73 | +// AsInt64 returns the value held by v as an int64. |
| 74 | +func (v Value) AsInt64() int64 { return 0 } // TODO (#4914): implement |
| 75 | + |
| 76 | +// AsBool returns the value held by v as a bool. |
| 77 | +func (v Value) AsBool() bool { return false } // TODO (#4914): implement |
| 78 | + |
| 79 | +// AsFloat64 returns the value held by v as a float64. |
| 80 | +func (v Value) AsFloat64() float64 { return 0 } // TODO (#4914): implement |
| 81 | + |
| 82 | +// AsBytes returns the value held by v as a []byte. |
| 83 | +func (v Value) AsBytes() []byte { return nil } // TODO (#4914): implement |
| 84 | + |
| 85 | +// AsList returns the value held by v as a []Value. |
| 86 | +func (v Value) AsList() []Value { return nil } // TODO (#4914): implement |
| 87 | + |
| 88 | +// AsMap returns the value held by v as a []KeyValue. |
| 89 | +func (v Value) AsMap() []KeyValue { return nil } // TODO (#4914): implement |
| 90 | + |
| 91 | +// Kind returns the Kind of v. |
| 92 | +func (v Value) Kind() Kind { return KindEmpty } // TODO (#4914): implement. |
| 93 | + |
| 94 | +// Empty returns if v does not hold any value. |
| 95 | +func (v Value) Empty() bool { return false } // TODO (#4914): implement |
| 96 | + |
| 97 | +// Equal returns if v is equal to w. |
| 98 | +func (v Value) Equal(w Value) bool { return false } // TODO (#4914): implement |
| 99 | + |
| 100 | +// An KeyValue is a key-value pair used to represent a log attribute (a |
| 101 | +// superset of [go.opentelemetry.io/otel/attribute.KeyValue]) and map item. |
| 102 | +type KeyValue struct { |
| 103 | + Key string |
| 104 | + Value Value |
| 105 | +} |
| 106 | + |
| 107 | +// Equal returns if a is equal to b. |
| 108 | +func (a KeyValue) Equal(b KeyValue) bool { return false } // TODO (#4914): implement |
| 109 | + |
| 110 | +// String returns an KeyValue for a string value. |
| 111 | +func String(key, value string) KeyValue { return KeyValue{} } // TODO (#4914): implement |
| 112 | + |
| 113 | +// Int64 returns an KeyValue for an int64 value. |
| 114 | +func Int64(key string, value int64) KeyValue { return KeyValue{} } // TODO (#4914): implement |
| 115 | + |
| 116 | +// Int returns an KeyValue for an int value. |
| 117 | +func Int(key string, value int) KeyValue { return KeyValue{} } // TODO (#4914): implement |
| 118 | + |
| 119 | +// Float64 returns an KeyValue for a float64 value. |
| 120 | +func Float64(key string, v float64) KeyValue { return KeyValue{} } // TODO (#4914): implement |
| 121 | + |
| 122 | +// Bool returns an KeyValue for a bool value. |
| 123 | +func Bool(key string, v bool) KeyValue { return KeyValue{} } // TODO (#4914): implement |
| 124 | + |
| 125 | +// Bytes returns an KeyValue for a []byte value. |
| 126 | +func Bytes(key string, v []byte) KeyValue { return KeyValue{} } // TODO (#4914): implement |
| 127 | + |
| 128 | +// List returns an KeyValue for a []Value value. |
| 129 | +func List(key string, args ...Value) KeyValue { return KeyValue{} } // TODO (#4914): implement |
| 130 | + |
| 131 | +// Map returns an KeyValue for a map value. |
| 132 | +func Map(key string, args ...KeyValue) KeyValue { return KeyValue{} } // TODO (#4914): implement |
0 commit comments