repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1 value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
rs/zerolog | log.go | With | func (l Logger) With() Context {
context := l.context
l.context = make([]byte, 0, 500)
if context != nil {
l.context = append(l.context, context...)
}
return Context{l}
} | go | func (l Logger) With() Context {
context := l.context
l.context = make([]byte, 0, 500)
if context != nil {
l.context = append(l.context, context...)
}
return Context{l}
} | [
"func",
"(",
"l",
"Logger",
")",
"With",
"(",
")",
"Context",
"{",
"context",
":=",
"l",
".",
"context",
"\n",
"l",
".",
"context",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
",",
"500",
")",
"\n",
"if",
"context",
"!=",
"nil",
"{",
"l",
"... | // With creates a child logger with the field added to its context. | [
"With",
"creates",
"a",
"child",
"logger",
"with",
"the",
"field",
"added",
"to",
"its",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L225-L232 | train |
rs/zerolog | log.go | UpdateContext | func (l *Logger) UpdateContext(update func(c Context) Context) {
if l == disabledLogger {
return
}
if cap(l.context) == 0 {
l.context = make([]byte, 0, 500)
}
c := update(Context{*l})
l.context = c.l.context
} | go | func (l *Logger) UpdateContext(update func(c Context) Context) {
if l == disabledLogger {
return
}
if cap(l.context) == 0 {
l.context = make([]byte, 0, 500)
}
c := update(Context{*l})
l.context = c.l.context
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"UpdateContext",
"(",
"update",
"func",
"(",
"c",
"Context",
")",
"Context",
")",
"{",
"if",
"l",
"==",
"disabledLogger",
"{",
"return",
"\n",
"}",
"\n",
"if",
"cap",
"(",
"l",
".",
"context",
")",
"==",
"0",
... | // UpdateContext updates the internal logger's context.
//
// Use this method with caution. If unsure, prefer the With method. | [
"UpdateContext",
"updates",
"the",
"internal",
"logger",
"s",
"context",
".",
"Use",
"this",
"method",
"with",
"caution",
".",
"If",
"unsure",
"prefer",
"the",
"With",
"method",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L237-L246 | train |
rs/zerolog | log.go | Level | func (l Logger) Level(lvl Level) Logger {
l.level = lvl
return l
} | go | func (l Logger) Level(lvl Level) Logger {
l.level = lvl
return l
} | [
"func",
"(",
"l",
"Logger",
")",
"Level",
"(",
"lvl",
"Level",
")",
"Logger",
"{",
"l",
".",
"level",
"=",
"lvl",
"\n",
"return",
"l",
"\n",
"}"
] | // Level creates a child logger with the minimum accepted level set to level. | [
"Level",
"creates",
"a",
"child",
"logger",
"with",
"the",
"minimum",
"accepted",
"level",
"set",
"to",
"level",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L249-L252 | train |
rs/zerolog | log.go | Sample | func (l Logger) Sample(s Sampler) Logger {
l.sampler = s
return l
} | go | func (l Logger) Sample(s Sampler) Logger {
l.sampler = s
return l
} | [
"func",
"(",
"l",
"Logger",
")",
"Sample",
"(",
"s",
"Sampler",
")",
"Logger",
"{",
"l",
".",
"sampler",
"=",
"s",
"\n",
"return",
"l",
"\n",
"}"
] | // Sample returns a logger with the s sampler. | [
"Sample",
"returns",
"a",
"logger",
"with",
"the",
"s",
"sampler",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L255-L258 | train |
rs/zerolog | log.go | Hook | func (l Logger) Hook(h Hook) Logger {
l.hooks = append(l.hooks, h)
return l
} | go | func (l Logger) Hook(h Hook) Logger {
l.hooks = append(l.hooks, h)
return l
} | [
"func",
"(",
"l",
"Logger",
")",
"Hook",
"(",
"h",
"Hook",
")",
"Logger",
"{",
"l",
".",
"hooks",
"=",
"append",
"(",
"l",
".",
"hooks",
",",
"h",
")",
"\n",
"return",
"l",
"\n",
"}"
] | // Hook returns a logger with the h Hook. | [
"Hook",
"returns",
"a",
"logger",
"with",
"the",
"h",
"Hook",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L261-L264 | train |
rs/zerolog | log.go | Err | func (l *Logger) Err(err error) *Event {
if err != nil {
return l.Error().Err(err)
} else {
return l.Info()
}
} | go | func (l *Logger) Err(err error) *Event {
if err != nil {
return l.Error().Err(err)
} else {
return l.Info()
}
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"Err",
"(",
"err",
"error",
")",
"*",
"Event",
"{",
"if",
"err",
"!=",
"nil",
"{",
"return",
"l",
".",
"Error",
"(",
")",
".",
"Err",
"(",
"err",
")",
"\n",
"}",
"else",
"{",
"return",
"l",
".",
"Info",
... | // Err starts a new message with error level with err as a field if not nil or
// with info level if err is nil.
//
// You must call Msg on the returned event in order to send the event. | [
"Err",
"starts",
"a",
"new",
"message",
"with",
"error",
"level",
"with",
"err",
"as",
"a",
"field",
"if",
"not",
"nil",
"or",
"with",
"info",
"level",
"if",
"err",
"is",
"nil",
".",
"You",
"must",
"call",
"Msg",
"on",
"the",
"returned",
"event",
"in... | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L298-L304 | train |
rs/zerolog | log.go | WithLevel | func (l *Logger) WithLevel(level Level) *Event {
switch level {
case DebugLevel:
return l.Debug()
case InfoLevel:
return l.Info()
case WarnLevel:
return l.Warn()
case ErrorLevel:
return l.Error()
case FatalLevel:
return l.newEvent(FatalLevel, nil)
case PanicLevel:
return l.newEvent(PanicLevel, nil)
case NoLevel:
return l.Log()
case Disabled:
return nil
default:
panic("zerolog: WithLevel(): invalid level: " + strconv.Itoa(int(level)))
}
} | go | func (l *Logger) WithLevel(level Level) *Event {
switch level {
case DebugLevel:
return l.Debug()
case InfoLevel:
return l.Info()
case WarnLevel:
return l.Warn()
case ErrorLevel:
return l.Error()
case FatalLevel:
return l.newEvent(FatalLevel, nil)
case PanicLevel:
return l.newEvent(PanicLevel, nil)
case NoLevel:
return l.Log()
case Disabled:
return nil
default:
panic("zerolog: WithLevel(): invalid level: " + strconv.Itoa(int(level)))
}
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"WithLevel",
"(",
"level",
"Level",
")",
"*",
"Event",
"{",
"switch",
"level",
"{",
"case",
"DebugLevel",
":",
"return",
"l",
".",
"Debug",
"(",
")",
"\n",
"case",
"InfoLevel",
":",
"return",
"l",
".",
"Info",
... | // WithLevel starts a new message with level. Unlike Fatal and Panic
// methods, WithLevel does not terminate the program or stop the ordinary
// flow of a gourotine when used with their respective levels.
//
// You must call Msg on the returned event in order to send the event. | [
"WithLevel",
"starts",
"a",
"new",
"message",
"with",
"level",
".",
"Unlike",
"Fatal",
"and",
"Panic",
"methods",
"WithLevel",
"does",
"not",
"terminate",
"the",
"program",
"or",
"stop",
"the",
"ordinary",
"flow",
"of",
"a",
"gourotine",
"when",
"used",
"wit... | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L327-L348 | train |
rs/zerolog | log.go | Print | func (l *Logger) Print(v ...interface{}) {
if e := l.Debug(); e.Enabled() {
e.Msg(fmt.Sprint(v...))
}
} | go | func (l *Logger) Print(v ...interface{}) {
if e := l.Debug(); e.Enabled() {
e.Msg(fmt.Sprint(v...))
}
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"Print",
"(",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"e",
":=",
"l",
".",
"Debug",
"(",
")",
";",
"e",
".",
"Enabled",
"(",
")",
"{",
"e",
".",
"Msg",
"(",
"fmt",
".",
"Sprint",
"(",
"v",
... | // Print sends a log event using debug level and no extra field.
// Arguments are handled in the manner of fmt.Print. | [
"Print",
"sends",
"a",
"log",
"event",
"using",
"debug",
"level",
"and",
"no",
"extra",
"field",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Print",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L360-L364 | train |
rs/zerolog | log.go | Printf | func (l *Logger) Printf(format string, v ...interface{}) {
if e := l.Debug(); e.Enabled() {
e.Msg(fmt.Sprintf(format, v...))
}
} | go | func (l *Logger) Printf(format string, v ...interface{}) {
if e := l.Debug(); e.Enabled() {
e.Msg(fmt.Sprintf(format, v...))
}
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"Printf",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"e",
":=",
"l",
".",
"Debug",
"(",
")",
";",
"e",
".",
"Enabled",
"(",
")",
"{",
"e",
".",
"Msg",
"(",
"fmt",
"... | // Printf sends a log event using debug level and no extra field.
// Arguments are handled in the manner of fmt.Printf. | [
"Printf",
"sends",
"a",
"log",
"event",
"using",
"debug",
"level",
"and",
"no",
"extra",
"field",
".",
"Arguments",
"are",
"handled",
"in",
"the",
"manner",
"of",
"fmt",
".",
"Printf",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L368-L372 | train |
rs/zerolog | log.go | Write | func (l Logger) Write(p []byte) (n int, err error) {
n = len(p)
if n > 0 && p[n-1] == '\n' {
// Trim CR added by stdlog.
p = p[0 : n-1]
}
l.Log().Msg(string(p))
return
} | go | func (l Logger) Write(p []byte) (n int, err error) {
n = len(p)
if n > 0 && p[n-1] == '\n' {
// Trim CR added by stdlog.
p = p[0 : n-1]
}
l.Log().Msg(string(p))
return
} | [
"func",
"(",
"l",
"Logger",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"n",
"=",
"len",
"(",
"p",
")",
"\n",
"if",
"n",
">",
"0",
"&&",
"p",
"[",
"n",
"-",
"1",
"]",
"==",
"'\\n'",
"{"... | // Write implements the io.Writer interface. This is useful to set as a writer
// for the standard library log. | [
"Write",
"implements",
"the",
"io",
".",
"Writer",
"interface",
".",
"This",
"is",
"useful",
"to",
"set",
"as",
"a",
"writer",
"for",
"the",
"standard",
"library",
"log",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L376-L384 | train |
rs/zerolog | log.go | should | func (l *Logger) should(lvl Level) bool {
if lvl < l.level || lvl < GlobalLevel() {
return false
}
if l.sampler != nil && !samplingDisabled() {
return l.sampler.Sample(lvl)
}
return true
} | go | func (l *Logger) should(lvl Level) bool {
if lvl < l.level || lvl < GlobalLevel() {
return false
}
if l.sampler != nil && !samplingDisabled() {
return l.sampler.Sample(lvl)
}
return true
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"should",
"(",
"lvl",
"Level",
")",
"bool",
"{",
"if",
"lvl",
"<",
"l",
".",
"level",
"||",
"lvl",
"<",
"GlobalLevel",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"l",
".",
"sampler",
"!=",
"ni... | // should returns true if the log event should be logged. | [
"should",
"returns",
"true",
"if",
"the",
"log",
"event",
"should",
"be",
"logged",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L404-L412 | train |
rs/zerolog | console.go | NewConsoleWriter | func NewConsoleWriter(options ...func(w *ConsoleWriter)) ConsoleWriter {
w := ConsoleWriter{
Out: os.Stdout,
TimeFormat: consoleDefaultTimeFormat,
PartsOrder: consoleDefaultPartsOrder(),
}
for _, opt := range options {
opt(&w)
}
return w
} | go | func NewConsoleWriter(options ...func(w *ConsoleWriter)) ConsoleWriter {
w := ConsoleWriter{
Out: os.Stdout,
TimeFormat: consoleDefaultTimeFormat,
PartsOrder: consoleDefaultPartsOrder(),
}
for _, opt := range options {
opt(&w)
}
return w
} | [
"func",
"NewConsoleWriter",
"(",
"options",
"...",
"func",
"(",
"w",
"*",
"ConsoleWriter",
")",
")",
"ConsoleWriter",
"{",
"w",
":=",
"ConsoleWriter",
"{",
"Out",
":",
"os",
".",
"Stdout",
",",
"TimeFormat",
":",
"consoleDefaultTimeFormat",
",",
"PartsOrder",
... | // NewConsoleWriter creates and initializes a new ConsoleWriter. | [
"NewConsoleWriter",
"creates",
"and",
"initializes",
"a",
"new",
"ConsoleWriter",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/console.go#L71-L83 | train |
rs/zerolog | console.go | Write | func (w ConsoleWriter) Write(p []byte) (n int, err error) {
if w.PartsOrder == nil {
w.PartsOrder = consoleDefaultPartsOrder()
}
var buf = consoleBufPool.Get().(*bytes.Buffer)
defer func() {
buf.Reset()
consoleBufPool.Put(buf)
}()
var evt map[string]interface{}
p = decodeIfBinaryToBytes(p)
d := json.NewDecoder(bytes.NewReader(p))
d.UseNumber()
err = d.Decode(&evt)
if err != nil {
return n, fmt.Errorf("cannot decode event: %s", err)
}
for _, p := range w.PartsOrder {
w.writePart(buf, evt, p)
}
w.writeFields(evt, buf)
err = buf.WriteByte('\n')
if err != nil {
return n, err
}
_, err = buf.WriteTo(w.Out)
return len(p), err
} | go | func (w ConsoleWriter) Write(p []byte) (n int, err error) {
if w.PartsOrder == nil {
w.PartsOrder = consoleDefaultPartsOrder()
}
var buf = consoleBufPool.Get().(*bytes.Buffer)
defer func() {
buf.Reset()
consoleBufPool.Put(buf)
}()
var evt map[string]interface{}
p = decodeIfBinaryToBytes(p)
d := json.NewDecoder(bytes.NewReader(p))
d.UseNumber()
err = d.Decode(&evt)
if err != nil {
return n, fmt.Errorf("cannot decode event: %s", err)
}
for _, p := range w.PartsOrder {
w.writePart(buf, evt, p)
}
w.writeFields(evt, buf)
err = buf.WriteByte('\n')
if err != nil {
return n, err
}
_, err = buf.WriteTo(w.Out)
return len(p), err
} | [
"func",
"(",
"w",
"ConsoleWriter",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"if",
"w",
".",
"PartsOrder",
"==",
"nil",
"{",
"w",
".",
"PartsOrder",
"=",
"consoleDefaultPartsOrder",
"(",
")",
"\n... | // Write transforms the JSON input with formatters and appends to w.Out. | [
"Write",
"transforms",
"the",
"JSON",
"input",
"with",
"formatters",
"and",
"appends",
"to",
"w",
".",
"Out",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/console.go#L86-L118 | train |
rs/zerolog | console.go | writeFields | func (w ConsoleWriter) writeFields(evt map[string]interface{}, buf *bytes.Buffer) {
var fields = make([]string, 0, len(evt))
for field := range evt {
switch field {
case LevelFieldName, TimestampFieldName, MessageFieldName, CallerFieldName:
continue
}
fields = append(fields, field)
}
sort.Strings(fields)
if len(fields) > 0 {
buf.WriteByte(' ')
}
// Move the "error" field to the front
ei := sort.Search(len(fields), func(i int) bool { return fields[i] >= ErrorFieldName })
if ei < len(fields) && fields[ei] == ErrorFieldName {
fields[ei] = ""
fields = append([]string{ErrorFieldName}, fields...)
var xfields = make([]string, 0, len(fields))
for _, field := range fields {
if field == "" { // Skip empty fields
continue
}
xfields = append(xfields, field)
}
fields = xfields
}
for i, field := range fields {
var fn Formatter
var fv Formatter
if field == ErrorFieldName {
if w.FormatErrFieldName == nil {
fn = consoleDefaultFormatErrFieldName(w.NoColor)
} else {
fn = w.FormatErrFieldName
}
if w.FormatErrFieldValue == nil {
fv = consoleDefaultFormatErrFieldValue(w.NoColor)
} else {
fv = w.FormatErrFieldValue
}
} else {
if w.FormatFieldName == nil {
fn = consoleDefaultFormatFieldName(w.NoColor)
} else {
fn = w.FormatFieldName
}
if w.FormatFieldValue == nil {
fv = consoleDefaultFormatFieldValue
} else {
fv = w.FormatFieldValue
}
}
buf.WriteString(fn(field))
switch fValue := evt[field].(type) {
case string:
if needsQuote(fValue) {
buf.WriteString(fv(strconv.Quote(fValue)))
} else {
buf.WriteString(fv(fValue))
}
case json.Number:
buf.WriteString(fv(fValue))
default:
b, err := json.Marshal(fValue)
if err != nil {
fmt.Fprintf(buf, colorize("[error: %v]", colorRed, w.NoColor), err)
} else {
fmt.Fprint(buf, fv(b))
}
}
if i < len(fields)-1 { // Skip space for last field
buf.WriteByte(' ')
}
}
} | go | func (w ConsoleWriter) writeFields(evt map[string]interface{}, buf *bytes.Buffer) {
var fields = make([]string, 0, len(evt))
for field := range evt {
switch field {
case LevelFieldName, TimestampFieldName, MessageFieldName, CallerFieldName:
continue
}
fields = append(fields, field)
}
sort.Strings(fields)
if len(fields) > 0 {
buf.WriteByte(' ')
}
// Move the "error" field to the front
ei := sort.Search(len(fields), func(i int) bool { return fields[i] >= ErrorFieldName })
if ei < len(fields) && fields[ei] == ErrorFieldName {
fields[ei] = ""
fields = append([]string{ErrorFieldName}, fields...)
var xfields = make([]string, 0, len(fields))
for _, field := range fields {
if field == "" { // Skip empty fields
continue
}
xfields = append(xfields, field)
}
fields = xfields
}
for i, field := range fields {
var fn Formatter
var fv Formatter
if field == ErrorFieldName {
if w.FormatErrFieldName == nil {
fn = consoleDefaultFormatErrFieldName(w.NoColor)
} else {
fn = w.FormatErrFieldName
}
if w.FormatErrFieldValue == nil {
fv = consoleDefaultFormatErrFieldValue(w.NoColor)
} else {
fv = w.FormatErrFieldValue
}
} else {
if w.FormatFieldName == nil {
fn = consoleDefaultFormatFieldName(w.NoColor)
} else {
fn = w.FormatFieldName
}
if w.FormatFieldValue == nil {
fv = consoleDefaultFormatFieldValue
} else {
fv = w.FormatFieldValue
}
}
buf.WriteString(fn(field))
switch fValue := evt[field].(type) {
case string:
if needsQuote(fValue) {
buf.WriteString(fv(strconv.Quote(fValue)))
} else {
buf.WriteString(fv(fValue))
}
case json.Number:
buf.WriteString(fv(fValue))
default:
b, err := json.Marshal(fValue)
if err != nil {
fmt.Fprintf(buf, colorize("[error: %v]", colorRed, w.NoColor), err)
} else {
fmt.Fprint(buf, fv(b))
}
}
if i < len(fields)-1 { // Skip space for last field
buf.WriteByte(' ')
}
}
} | [
"func",
"(",
"w",
"ConsoleWriter",
")",
"writeFields",
"(",
"evt",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"buf",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"var",
"fields",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"... | // writeFields appends formatted key-value pairs to buf. | [
"writeFields",
"appends",
"formatted",
"key",
"-",
"value",
"pairs",
"to",
"buf",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/console.go#L121-L205 | train |
rs/zerolog | console.go | writePart | func (w ConsoleWriter) writePart(buf *bytes.Buffer, evt map[string]interface{}, p string) {
var f Formatter
switch p {
case LevelFieldName:
if w.FormatLevel == nil {
f = consoleDefaultFormatLevel(w.NoColor)
} else {
f = w.FormatLevel
}
case TimestampFieldName:
if w.FormatTimestamp == nil {
f = consoleDefaultFormatTimestamp(w.TimeFormat, w.NoColor)
} else {
f = w.FormatTimestamp
}
case MessageFieldName:
if w.FormatMessage == nil {
f = consoleDefaultFormatMessage
} else {
f = w.FormatMessage
}
case CallerFieldName:
if w.FormatCaller == nil {
f = consoleDefaultFormatCaller(w.NoColor)
} else {
f = w.FormatCaller
}
default:
if w.FormatFieldValue == nil {
f = consoleDefaultFormatFieldValue
} else {
f = w.FormatFieldValue
}
}
var s = f(evt[p])
if len(s) > 0 {
buf.WriteString(s)
if p != w.PartsOrder[len(w.PartsOrder)-1] { // Skip space for last part
buf.WriteByte(' ')
}
}
} | go | func (w ConsoleWriter) writePart(buf *bytes.Buffer, evt map[string]interface{}, p string) {
var f Formatter
switch p {
case LevelFieldName:
if w.FormatLevel == nil {
f = consoleDefaultFormatLevel(w.NoColor)
} else {
f = w.FormatLevel
}
case TimestampFieldName:
if w.FormatTimestamp == nil {
f = consoleDefaultFormatTimestamp(w.TimeFormat, w.NoColor)
} else {
f = w.FormatTimestamp
}
case MessageFieldName:
if w.FormatMessage == nil {
f = consoleDefaultFormatMessage
} else {
f = w.FormatMessage
}
case CallerFieldName:
if w.FormatCaller == nil {
f = consoleDefaultFormatCaller(w.NoColor)
} else {
f = w.FormatCaller
}
default:
if w.FormatFieldValue == nil {
f = consoleDefaultFormatFieldValue
} else {
f = w.FormatFieldValue
}
}
var s = f(evt[p])
if len(s) > 0 {
buf.WriteString(s)
if p != w.PartsOrder[len(w.PartsOrder)-1] { // Skip space for last part
buf.WriteByte(' ')
}
}
} | [
"func",
"(",
"w",
"ConsoleWriter",
")",
"writePart",
"(",
"buf",
"*",
"bytes",
".",
"Buffer",
",",
"evt",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"p",
"string",
")",
"{",
"var",
"f",
"Formatter",
"\n\n",
"switch",
"p",
"{",
"case",
"... | // writePart appends a formatted part to buf. | [
"writePart",
"appends",
"a",
"formatted",
"part",
"to",
"buf",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/console.go#L208-L252 | train |
rs/zerolog | console.go | needsQuote | func needsQuote(s string) bool {
for i := range s {
if s[i] < 0x20 || s[i] > 0x7e || s[i] == ' ' || s[i] == '\\' || s[i] == '"' {
return true
}
}
return false
} | go | func needsQuote(s string) bool {
for i := range s {
if s[i] < 0x20 || s[i] > 0x7e || s[i] == ' ' || s[i] == '\\' || s[i] == '"' {
return true
}
}
return false
} | [
"func",
"needsQuote",
"(",
"s",
"string",
")",
"bool",
"{",
"for",
"i",
":=",
"range",
"s",
"{",
"if",
"s",
"[",
"i",
"]",
"<",
"0x20",
"||",
"s",
"[",
"i",
"]",
">",
"0x7e",
"||",
"s",
"[",
"i",
"]",
"==",
"' '",
"||",
"s",
"[",
"i",
"]"... | // needsQuote returns true when the string s should be quoted in output. | [
"needsQuote",
"returns",
"true",
"when",
"the",
"string",
"s",
"should",
"be",
"quoted",
"in",
"output",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/console.go#L255-L262 | train |
rs/zerolog | console.go | colorize | func colorize(s interface{}, c int, disabled bool) string {
if disabled {
return fmt.Sprintf("%s", s)
}
return fmt.Sprintf("\x1b[%dm%v\x1b[0m", c, s)
} | go | func colorize(s interface{}, c int, disabled bool) string {
if disabled {
return fmt.Sprintf("%s", s)
}
return fmt.Sprintf("\x1b[%dm%v\x1b[0m", c, s)
} | [
"func",
"colorize",
"(",
"s",
"interface",
"{",
"}",
",",
"c",
"int",
",",
"disabled",
"bool",
")",
"string",
"{",
"if",
"disabled",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
")",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Spr... | // colorize returns the string s wrapped in ANSI code c, unless disabled is true. | [
"colorize",
"returns",
"the",
"string",
"s",
"wrapped",
"in",
"ANSI",
"code",
"c",
"unless",
"disabled",
"is",
"true",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/console.go#L265-L270 | train |
rs/zerolog | syslog.go | WriteLevel | func (sw syslogWriter) WriteLevel(level Level, p []byte) (n int, err error) {
switch level {
case DebugLevel:
err = sw.w.Debug(string(p))
case InfoLevel:
err = sw.w.Info(string(p))
case WarnLevel:
err = sw.w.Warning(string(p))
case ErrorLevel:
err = sw.w.Err(string(p))
case FatalLevel:
err = sw.w.Emerg(string(p))
case PanicLevel:
err = sw.w.Crit(string(p))
case NoLevel:
err = sw.w.Info(string(p))
default:
panic("invalid level")
}
n = len(p)
return
} | go | func (sw syslogWriter) WriteLevel(level Level, p []byte) (n int, err error) {
switch level {
case DebugLevel:
err = sw.w.Debug(string(p))
case InfoLevel:
err = sw.w.Info(string(p))
case WarnLevel:
err = sw.w.Warning(string(p))
case ErrorLevel:
err = sw.w.Err(string(p))
case FatalLevel:
err = sw.w.Emerg(string(p))
case PanicLevel:
err = sw.w.Crit(string(p))
case NoLevel:
err = sw.w.Info(string(p))
default:
panic("invalid level")
}
n = len(p)
return
} | [
"func",
"(",
"sw",
"syslogWriter",
")",
"WriteLevel",
"(",
"level",
"Level",
",",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"switch",
"level",
"{",
"case",
"DebugLevel",
":",
"err",
"=",
"sw",
".",
"w",
".",
"Deb... | // WriteLevel implements LevelWriter interface. | [
"WriteLevel",
"implements",
"LevelWriter",
"interface",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/syslog.go#L36-L57 | train |
rs/zerolog | internal/cbor/time.go | AppendTime | func (e Encoder) AppendTime(dst []byte, t time.Time, unused string) []byte {
utc := t.UTC()
if utc.Nanosecond() == 0 {
return appendIntegerTimestamp(dst, utc)
}
return e.appendFloatTimestamp(dst, utc)
} | go | func (e Encoder) AppendTime(dst []byte, t time.Time, unused string) []byte {
utc := t.UTC()
if utc.Nanosecond() == 0 {
return appendIntegerTimestamp(dst, utc)
}
return e.appendFloatTimestamp(dst, utc)
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendTime",
"(",
"dst",
"[",
"]",
"byte",
",",
"t",
"time",
".",
"Time",
",",
"unused",
"string",
")",
"[",
"]",
"byte",
"{",
"utc",
":=",
"t",
".",
"UTC",
"(",
")",
"\n",
"if",
"utc",
".",
"Nanosecond",
"(",... | // AppendTime encodes and adds a timestamp to the dst byte array. | [
"AppendTime",
"encodes",
"and",
"adds",
"a",
"timestamp",
"to",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/time.go#L36-L42 | train |
rs/zerolog | internal/cbor/time.go | AppendTimes | func (e Encoder) AppendTimes(dst []byte, vals []time.Time, unused string) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, t := range vals {
dst = e.AppendTime(dst, t, unused)
}
return dst
} | go | func (e Encoder) AppendTimes(dst []byte, vals []time.Time, unused string) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, t := range vals {
dst = e.AppendTime(dst, t, unused)
}
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendTimes",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"time",
".",
"Time",
",",
"unused",
"string",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeArray",
"\n",
"l",
":=",
"len",
"(",
"vals",
... | // AppendTimes encodes and adds an array of timestamps to the dst byte array. | [
"AppendTimes",
"encodes",
"and",
"adds",
"an",
"array",
"of",
"timestamps",
"to",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/time.go#L45-L62 | train |
rs/zerolog | internal/json/types.go | AppendArrayDelim | func (Encoder) AppendArrayDelim(dst []byte) []byte {
if len(dst) > 0 {
return append(dst, ',')
}
return dst
} | go | func (Encoder) AppendArrayDelim(dst []byte) []byte {
if len(dst) > 0 {
return append(dst, ',')
}
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendArrayDelim",
"(",
"dst",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"dst",
")",
">",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"','",
")",
"\n",
"}",
"\n",
"return",
"dst",
"\n",
"}"... | // AppendArrayDelim adds markers to indicate end of a particular array element. | [
"AppendArrayDelim",
"adds",
"markers",
"to",
"indicate",
"end",
"of",
"a",
"particular",
"array",
"element",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L42-L47 | train |
rs/zerolog | internal/json/types.go | AppendBool | func (Encoder) AppendBool(dst []byte, val bool) []byte {
return strconv.AppendBool(dst, val)
} | go | func (Encoder) AppendBool(dst []byte, val bool) []byte {
return strconv.AppendBool(dst, val)
} | [
"func",
"(",
"Encoder",
")",
"AppendBool",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"bool",
")",
"[",
"]",
"byte",
"{",
"return",
"strconv",
".",
"AppendBool",
"(",
"dst",
",",
"val",
")",
"\n",
"}"
] | // AppendBool converts the input bool to a string and
// appends the encoded string to the input byte slice. | [
"AppendBool",
"converts",
"the",
"input",
"bool",
"to",
"a",
"string",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L51-L53 | train |
rs/zerolog | internal/json/types.go | AppendBools | func (Encoder) AppendBools(dst []byte, vals []bool) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendBool(dst, vals[0])
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendBool(append(dst, ','), val)
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendBools(dst []byte, vals []bool) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendBool(dst, vals[0])
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendBool(append(dst, ','), val)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendBools",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"bool",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",
")",
"... | // AppendBools encodes the input bools to json and
// appends the encoded string list to the input byte slice. | [
"AppendBools",
"encodes",
"the",
"input",
"bools",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L57-L70 | train |
rs/zerolog | internal/json/types.go | AppendInt | func (Encoder) AppendInt(dst []byte, val int) []byte {
return strconv.AppendInt(dst, int64(val), 10)
} | go | func (Encoder) AppendInt(dst []byte, val int) []byte {
return strconv.AppendInt(dst, int64(val), 10)
} | [
"func",
"(",
"Encoder",
")",
"AppendInt",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"int",
")",
"[",
"]",
"byte",
"{",
"return",
"strconv",
".",
"AppendInt",
"(",
"dst",
",",
"int64",
"(",
"val",
")",
",",
"10",
")",
"\n",
"}"
] | // AppendInt converts the input int to a string and
// appends the encoded string to the input byte slice. | [
"AppendInt",
"converts",
"the",
"input",
"int",
"to",
"a",
"string",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L74-L76 | train |
rs/zerolog | internal/json/types.go | AppendInts | func (Encoder) AppendInts(dst []byte, vals []int) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendInt(dst, int64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendInt(append(dst, ','), int64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendInts(dst []byte, vals []int) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendInt(dst, int64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendInt(append(dst, ','), int64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendInts",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"int",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",
")",
"\n... | // AppendInts encodes the input ints to json and
// appends the encoded string list to the input byte slice. | [
"AppendInts",
"encodes",
"the",
"input",
"ints",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L80-L93 | train |
rs/zerolog | internal/json/types.go | AppendInts8 | func (Encoder) AppendInts8(dst []byte, vals []int8) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendInt(dst, int64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendInt(append(dst, ','), int64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendInts8(dst []byte, vals []int8) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendInt(dst, int64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendInt(append(dst, ','), int64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendInts8",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"int8",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",
")",
"... | // AppendInts8 encodes the input int8s to json and
// appends the encoded string list to the input byte slice. | [
"AppendInts8",
"encodes",
"the",
"input",
"int8s",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L103-L116 | train |
rs/zerolog | internal/json/types.go | AppendInt16 | func (Encoder) AppendInt16(dst []byte, val int16) []byte {
return strconv.AppendInt(dst, int64(val), 10)
} | go | func (Encoder) AppendInt16(dst []byte, val int16) []byte {
return strconv.AppendInt(dst, int64(val), 10)
} | [
"func",
"(",
"Encoder",
")",
"AppendInt16",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"int16",
")",
"[",
"]",
"byte",
"{",
"return",
"strconv",
".",
"AppendInt",
"(",
"dst",
",",
"int64",
"(",
"val",
")",
",",
"10",
")",
"\n",
"}"
] | // AppendInt16 converts the input int16 to a string and
// appends the encoded string to the input byte slice. | [
"AppendInt16",
"converts",
"the",
"input",
"int16",
"to",
"a",
"string",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L120-L122 | train |
rs/zerolog | internal/json/types.go | AppendInts16 | func (Encoder) AppendInts16(dst []byte, vals []int16) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendInt(dst, int64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendInt(append(dst, ','), int64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendInts16(dst []byte, vals []int16) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendInt(dst, int64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendInt(append(dst, ','), int64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendInts16",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"int16",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",
")",
... | // AppendInts16 encodes the input int16s to json and
// appends the encoded string list to the input byte slice. | [
"AppendInts16",
"encodes",
"the",
"input",
"int16s",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L126-L139 | train |
rs/zerolog | internal/json/types.go | AppendInt32 | func (Encoder) AppendInt32(dst []byte, val int32) []byte {
return strconv.AppendInt(dst, int64(val), 10)
} | go | func (Encoder) AppendInt32(dst []byte, val int32) []byte {
return strconv.AppendInt(dst, int64(val), 10)
} | [
"func",
"(",
"Encoder",
")",
"AppendInt32",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"int32",
")",
"[",
"]",
"byte",
"{",
"return",
"strconv",
".",
"AppendInt",
"(",
"dst",
",",
"int64",
"(",
"val",
")",
",",
"10",
")",
"\n",
"}"
] | // AppendInt32 converts the input int32 to a string and
// appends the encoded string to the input byte slice. | [
"AppendInt32",
"converts",
"the",
"input",
"int32",
"to",
"a",
"string",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L143-L145 | train |
rs/zerolog | internal/json/types.go | AppendInts32 | func (Encoder) AppendInts32(dst []byte, vals []int32) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendInt(dst, int64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendInt(append(dst, ','), int64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendInts32(dst []byte, vals []int32) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendInt(dst, int64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendInt(append(dst, ','), int64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendInts32",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"int32",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",
")",
... | // AppendInts32 encodes the input int32s to json and
// appends the encoded string list to the input byte slice. | [
"AppendInts32",
"encodes",
"the",
"input",
"int32s",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L149-L162 | train |
rs/zerolog | internal/json/types.go | AppendInt64 | func (Encoder) AppendInt64(dst []byte, val int64) []byte {
return strconv.AppendInt(dst, val, 10)
} | go | func (Encoder) AppendInt64(dst []byte, val int64) []byte {
return strconv.AppendInt(dst, val, 10)
} | [
"func",
"(",
"Encoder",
")",
"AppendInt64",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"int64",
")",
"[",
"]",
"byte",
"{",
"return",
"strconv",
".",
"AppendInt",
"(",
"dst",
",",
"val",
",",
"10",
")",
"\n",
"}"
] | // AppendInt64 converts the input int64 to a string and
// appends the encoded string to the input byte slice. | [
"AppendInt64",
"converts",
"the",
"input",
"int64",
"to",
"a",
"string",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L166-L168 | train |
rs/zerolog | internal/json/types.go | AppendInts64 | func (Encoder) AppendInts64(dst []byte, vals []int64) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendInt(dst, vals[0], 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendInt(append(dst, ','), val, 10)
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendInts64(dst []byte, vals []int64) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendInt(dst, vals[0], 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendInt(append(dst, ','), val, 10)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendInts64",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"int64",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",
")",
... | // AppendInts64 encodes the input int64s to json and
// appends the encoded string list to the input byte slice. | [
"AppendInts64",
"encodes",
"the",
"input",
"int64s",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L172-L185 | train |
rs/zerolog | internal/json/types.go | AppendUint | func (Encoder) AppendUint(dst []byte, val uint) []byte {
return strconv.AppendUint(dst, uint64(val), 10)
} | go | func (Encoder) AppendUint(dst []byte, val uint) []byte {
return strconv.AppendUint(dst, uint64(val), 10)
} | [
"func",
"(",
"Encoder",
")",
"AppendUint",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"uint",
")",
"[",
"]",
"byte",
"{",
"return",
"strconv",
".",
"AppendUint",
"(",
"dst",
",",
"uint64",
"(",
"val",
")",
",",
"10",
")",
"\n",
"}"
] | // AppendUint converts the input uint to a string and
// appends the encoded string to the input byte slice. | [
"AppendUint",
"converts",
"the",
"input",
"uint",
"to",
"a",
"string",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L189-L191 | train |
rs/zerolog | internal/json/types.go | AppendUints | func (Encoder) AppendUints(dst []byte, vals []uint) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendUint(dst, uint64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendUint(append(dst, ','), uint64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendUints(dst []byte, vals []uint) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendUint(dst, uint64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendUint(append(dst, ','), uint64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendUints",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"uint",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",
")",
"... | // AppendUints encodes the input uints to json and
// appends the encoded string list to the input byte slice. | [
"AppendUints",
"encodes",
"the",
"input",
"uints",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L195-L208 | train |
rs/zerolog | internal/json/types.go | AppendUint8 | func (Encoder) AppendUint8(dst []byte, val uint8) []byte {
return strconv.AppendUint(dst, uint64(val), 10)
} | go | func (Encoder) AppendUint8(dst []byte, val uint8) []byte {
return strconv.AppendUint(dst, uint64(val), 10)
} | [
"func",
"(",
"Encoder",
")",
"AppendUint8",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"uint8",
")",
"[",
"]",
"byte",
"{",
"return",
"strconv",
".",
"AppendUint",
"(",
"dst",
",",
"uint64",
"(",
"val",
")",
",",
"10",
")",
"\n",
"}"
] | // AppendUint8 converts the input uint8 to a string and
// appends the encoded string to the input byte slice. | [
"AppendUint8",
"converts",
"the",
"input",
"uint8",
"to",
"a",
"string",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L212-L214 | train |
rs/zerolog | internal/json/types.go | AppendUints8 | func (Encoder) AppendUints8(dst []byte, vals []uint8) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendUint(dst, uint64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendUint(append(dst, ','), uint64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendUints8(dst []byte, vals []uint8) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendUint(dst, uint64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendUint(append(dst, ','), uint64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendUints8",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"uint8",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",
")",
... | // AppendUints8 encodes the input uint8s to json and
// appends the encoded string list to the input byte slice. | [
"AppendUints8",
"encodes",
"the",
"input",
"uint8s",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L218-L231 | train |
rs/zerolog | internal/json/types.go | AppendUint16 | func (Encoder) AppendUint16(dst []byte, val uint16) []byte {
return strconv.AppendUint(dst, uint64(val), 10)
} | go | func (Encoder) AppendUint16(dst []byte, val uint16) []byte {
return strconv.AppendUint(dst, uint64(val), 10)
} | [
"func",
"(",
"Encoder",
")",
"AppendUint16",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"uint16",
")",
"[",
"]",
"byte",
"{",
"return",
"strconv",
".",
"AppendUint",
"(",
"dst",
",",
"uint64",
"(",
"val",
")",
",",
"10",
")",
"\n",
"}"
] | // AppendUint16 converts the input uint16 to a string and
// appends the encoded string to the input byte slice. | [
"AppendUint16",
"converts",
"the",
"input",
"uint16",
"to",
"a",
"string",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L235-L237 | train |
rs/zerolog | internal/json/types.go | AppendUints16 | func (Encoder) AppendUints16(dst []byte, vals []uint16) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendUint(dst, uint64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendUint(append(dst, ','), uint64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendUints16(dst []byte, vals []uint16) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendUint(dst, uint64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendUint(append(dst, ','), uint64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendUints16",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"uint16",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",
")",... | // AppendUints16 encodes the input uint16s to json and
// appends the encoded string list to the input byte slice. | [
"AppendUints16",
"encodes",
"the",
"input",
"uint16s",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L241-L254 | train |
rs/zerolog | internal/json/types.go | AppendUint32 | func (Encoder) AppendUint32(dst []byte, val uint32) []byte {
return strconv.AppendUint(dst, uint64(val), 10)
} | go | func (Encoder) AppendUint32(dst []byte, val uint32) []byte {
return strconv.AppendUint(dst, uint64(val), 10)
} | [
"func",
"(",
"Encoder",
")",
"AppendUint32",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"uint32",
")",
"[",
"]",
"byte",
"{",
"return",
"strconv",
".",
"AppendUint",
"(",
"dst",
",",
"uint64",
"(",
"val",
")",
",",
"10",
")",
"\n",
"}"
] | // AppendUint32 converts the input uint32 to a string and
// appends the encoded string to the input byte slice. | [
"AppendUint32",
"converts",
"the",
"input",
"uint32",
"to",
"a",
"string",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L258-L260 | train |
rs/zerolog | internal/json/types.go | AppendUints32 | func (Encoder) AppendUints32(dst []byte, vals []uint32) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendUint(dst, uint64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendUint(append(dst, ','), uint64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendUints32(dst []byte, vals []uint32) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendUint(dst, uint64(vals[0]), 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendUint(append(dst, ','), uint64(val), 10)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendUints32",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"uint32",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",
")",... | // AppendUints32 encodes the input uint32s to json and
// appends the encoded string list to the input byte slice. | [
"AppendUints32",
"encodes",
"the",
"input",
"uint32s",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L264-L277 | train |
rs/zerolog | internal/json/types.go | AppendUint64 | func (Encoder) AppendUint64(dst []byte, val uint64) []byte {
return strconv.AppendUint(dst, uint64(val), 10)
} | go | func (Encoder) AppendUint64(dst []byte, val uint64) []byte {
return strconv.AppendUint(dst, uint64(val), 10)
} | [
"func",
"(",
"Encoder",
")",
"AppendUint64",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"uint64",
")",
"[",
"]",
"byte",
"{",
"return",
"strconv",
".",
"AppendUint",
"(",
"dst",
",",
"uint64",
"(",
"val",
")",
",",
"10",
")",
"\n",
"}"
] | // AppendUint64 converts the input uint64 to a string and
// appends the encoded string to the input byte slice. | [
"AppendUint64",
"converts",
"the",
"input",
"uint64",
"to",
"a",
"string",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L281-L283 | train |
rs/zerolog | internal/json/types.go | AppendUints64 | func (Encoder) AppendUints64(dst []byte, vals []uint64) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendUint(dst, vals[0], 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendUint(append(dst, ','), val, 10)
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendUints64(dst []byte, vals []uint64) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = strconv.AppendUint(dst, vals[0], 10)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = strconv.AppendUint(append(dst, ','), val, 10)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendUints64",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"uint64",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",
")",... | // AppendUints64 encodes the input uint64s to json and
// appends the encoded string list to the input byte slice. | [
"AppendUints64",
"encodes",
"the",
"input",
"uint64s",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L287-L300 | train |
rs/zerolog | internal/json/types.go | AppendFloat32 | func (Encoder) AppendFloat32(dst []byte, val float32) []byte {
return appendFloat(dst, float64(val), 32)
} | go | func (Encoder) AppendFloat32(dst []byte, val float32) []byte {
return appendFloat(dst, float64(val), 32)
} | [
"func",
"(",
"Encoder",
")",
"AppendFloat32",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"float32",
")",
"[",
"]",
"byte",
"{",
"return",
"appendFloat",
"(",
"dst",
",",
"float64",
"(",
"val",
")",
",",
"32",
")",
"\n",
"}"
] | // AppendFloat32 converts the input float32 to a string and
// appends the encoded string to the input byte slice. | [
"AppendFloat32",
"converts",
"the",
"input",
"float32",
"to",
"a",
"string",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L319-L321 | train |
rs/zerolog | internal/json/types.go | AppendFloats32 | func (Encoder) AppendFloats32(dst []byte, vals []float32) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = appendFloat(dst, float64(vals[0]), 32)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = appendFloat(append(dst, ','), float64(val), 32)
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendFloats32(dst []byte, vals []float32) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = appendFloat(dst, float64(vals[0]), 32)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = appendFloat(append(dst, ','), float64(val), 32)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendFloats32",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"float32",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",
")... | // AppendFloats32 encodes the input float32s to json and
// appends the encoded string list to the input byte slice. | [
"AppendFloats32",
"encodes",
"the",
"input",
"float32s",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L325-L338 | train |
rs/zerolog | internal/json/types.go | AppendFloat64 | func (Encoder) AppendFloat64(dst []byte, val float64) []byte {
return appendFloat(dst, val, 64)
} | go | func (Encoder) AppendFloat64(dst []byte, val float64) []byte {
return appendFloat(dst, val, 64)
} | [
"func",
"(",
"Encoder",
")",
"AppendFloat64",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"float64",
")",
"[",
"]",
"byte",
"{",
"return",
"appendFloat",
"(",
"dst",
",",
"val",
",",
"64",
")",
"\n",
"}"
] | // AppendFloat64 converts the input float64 to a string and
// appends the encoded string to the input byte slice. | [
"AppendFloat64",
"converts",
"the",
"input",
"float64",
"to",
"a",
"string",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L342-L344 | train |
rs/zerolog | internal/json/types.go | AppendFloats64 | func (Encoder) AppendFloats64(dst []byte, vals []float64) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = appendFloat(dst, vals[0], 32)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = appendFloat(append(dst, ','), val, 64)
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendFloats64(dst []byte, vals []float64) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = appendFloat(dst, vals[0], 32)
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = appendFloat(append(dst, ','), val, 64)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendFloats64",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"float64",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",
")... | // AppendFloats64 encodes the input float64s to json and
// appends the encoded string list to the input byte slice. | [
"AppendFloats64",
"encodes",
"the",
"input",
"float64s",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L348-L361 | train |
rs/zerolog | internal/json/types.go | AppendObjectData | func (Encoder) AppendObjectData(dst []byte, o []byte) []byte {
// Two conditions we want to put a ',' between existing content and
// new content:
// 1. new content starts with '{' - which shd be dropped OR
// 2. existing content has already other fields
if o[0] == '{' {
o[0] = ','
} else if len(dst) > 1 {
dst = append(dst, ',')
}
return append(dst, o...)
} | go | func (Encoder) AppendObjectData(dst []byte, o []byte) []byte {
// Two conditions we want to put a ',' between existing content and
// new content:
// 1. new content starts with '{' - which shd be dropped OR
// 2. existing content has already other fields
if o[0] == '{' {
o[0] = ','
} else if len(dst) > 1 {
dst = append(dst, ',')
}
return append(dst, o...)
} | [
"func",
"(",
"Encoder",
")",
"AppendObjectData",
"(",
"dst",
"[",
"]",
"byte",
",",
"o",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"// Two conditions we want to put a ',' between existing content and",
"// new content:",
"// 1. new content starts with '{' - which shd ... | // AppendObjectData takes in an object that is already in a byte array
// and adds it to the dst. | [
"AppendObjectData",
"takes",
"in",
"an",
"object",
"that",
"is",
"already",
"in",
"a",
"byte",
"array",
"and",
"adds",
"it",
"to",
"the",
"dst",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L375-L386 | train |
rs/zerolog | internal/json/types.go | AppendIPAddr | func (e Encoder) AppendIPAddr(dst []byte, ip net.IP) []byte {
return e.AppendString(dst, ip.String())
} | go | func (e Encoder) AppendIPAddr(dst []byte, ip net.IP) []byte {
return e.AppendString(dst, ip.String())
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendIPAddr",
"(",
"dst",
"[",
"]",
"byte",
",",
"ip",
"net",
".",
"IP",
")",
"[",
"]",
"byte",
"{",
"return",
"e",
".",
"AppendString",
"(",
"dst",
",",
"ip",
".",
"String",
"(",
")",
")",
"\n",
"}"
] | // AppendIPAddr adds IPv4 or IPv6 address to dst. | [
"AppendIPAddr",
"adds",
"IPv4",
"or",
"IPv6",
"address",
"to",
"dst",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L389-L391 | train |
rs/zerolog | internal/json/types.go | AppendMACAddr | func (e Encoder) AppendMACAddr(dst []byte, ha net.HardwareAddr) []byte {
return e.AppendString(dst, ha.String())
} | go | func (e Encoder) AppendMACAddr(dst []byte, ha net.HardwareAddr) []byte {
return e.AppendString(dst, ha.String())
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendMACAddr",
"(",
"dst",
"[",
"]",
"byte",
",",
"ha",
"net",
".",
"HardwareAddr",
")",
"[",
"]",
"byte",
"{",
"return",
"e",
".",
"AppendString",
"(",
"dst",
",",
"ha",
".",
"String",
"(",
")",
")",
"\n",
"}"... | // AppendMACAddr adds MAC address to dst. | [
"AppendMACAddr",
"adds",
"MAC",
"address",
"to",
"dst",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L400-L402 | train |
rs/zerolog | journald/journald.go | levelToJPrio | func levelToJPrio(zLevel string) journal.Priority {
lvl, _ := zerolog.ParseLevel(zLevel)
switch lvl {
case zerolog.DebugLevel:
return journal.PriDebug
case zerolog.InfoLevel:
return journal.PriInfo
case zerolog.WarnLevel:
return journal.PriWarning
case zerolog.ErrorLevel:
return journal.PriErr
case zerolog.FatalLevel:
return journal.PriCrit
case zerolog.PanicLevel:
return journal.PriEmerg
case zerolog.NoLevel:
return journal.PriNotice
}
return defaultJournalDPrio
} | go | func levelToJPrio(zLevel string) journal.Priority {
lvl, _ := zerolog.ParseLevel(zLevel)
switch lvl {
case zerolog.DebugLevel:
return journal.PriDebug
case zerolog.InfoLevel:
return journal.PriInfo
case zerolog.WarnLevel:
return journal.PriWarning
case zerolog.ErrorLevel:
return journal.PriErr
case zerolog.FatalLevel:
return journal.PriCrit
case zerolog.PanicLevel:
return journal.PriEmerg
case zerolog.NoLevel:
return journal.PriNotice
}
return defaultJournalDPrio
} | [
"func",
"levelToJPrio",
"(",
"zLevel",
"string",
")",
"journal",
".",
"Priority",
"{",
"lvl",
",",
"_",
":=",
"zerolog",
".",
"ParseLevel",
"(",
"zLevel",
")",
"\n\n",
"switch",
"lvl",
"{",
"case",
"zerolog",
".",
"DebugLevel",
":",
"return",
"journal",
... | // levelToJPrio converts zerolog Level string into
// journalD's priority values. JournalD has more
// priorities than zerolog. | [
"levelToJPrio",
"converts",
"zerolog",
"Level",
"string",
"into",
"journalD",
"s",
"priority",
"values",
".",
"JournalD",
"has",
"more",
"priorities",
"than",
"zerolog",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/journald/journald.go#L46-L66 | train |
rs/zerolog | diode/internal/diodes/waiter.go | NewWaiter | func NewWaiter(d Diode, opts ...WaiterConfigOption) *Waiter {
w := new(Waiter)
w.Diode = d
w.c = sync.NewCond(&w.mu)
w.ctx = context.Background()
for _, opt := range opts {
opt(w)
}
go func() {
<-w.ctx.Done()
w.c.Broadcast()
}()
return w
} | go | func NewWaiter(d Diode, opts ...WaiterConfigOption) *Waiter {
w := new(Waiter)
w.Diode = d
w.c = sync.NewCond(&w.mu)
w.ctx = context.Background()
for _, opt := range opts {
opt(w)
}
go func() {
<-w.ctx.Done()
w.c.Broadcast()
}()
return w
} | [
"func",
"NewWaiter",
"(",
"d",
"Diode",
",",
"opts",
"...",
"WaiterConfigOption",
")",
"*",
"Waiter",
"{",
"w",
":=",
"new",
"(",
"Waiter",
")",
"\n",
"w",
".",
"Diode",
"=",
"d",
"\n",
"w",
".",
"c",
"=",
"sync",
".",
"NewCond",
"(",
"&",
"w",
... | // NewWaiter returns a new Waiter that wraps the given diode. | [
"NewWaiter",
"returns",
"a",
"new",
"Waiter",
"that",
"wraps",
"the",
"given",
"diode",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/diode/internal/diodes/waiter.go#L30-L46 | train |
rs/zerolog | diode/internal/diodes/waiter.go | Set | func (w *Waiter) Set(data GenericDataType) {
w.Diode.Set(data)
w.c.Broadcast()
} | go | func (w *Waiter) Set(data GenericDataType) {
w.Diode.Set(data)
w.c.Broadcast()
} | [
"func",
"(",
"w",
"*",
"Waiter",
")",
"Set",
"(",
"data",
"GenericDataType",
")",
"{",
"w",
".",
"Diode",
".",
"Set",
"(",
"data",
")",
"\n",
"w",
".",
"c",
".",
"Broadcast",
"(",
")",
"\n",
"}"
] | // Set invokes the wrapped diode's Set with the given data and uses Broadcast
// to wake up any readers. | [
"Set",
"invokes",
"the",
"wrapped",
"diode",
"s",
"Set",
"with",
"the",
"given",
"data",
"and",
"uses",
"Broadcast",
"to",
"wake",
"up",
"any",
"readers",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/diode/internal/diodes/waiter.go#L50-L53 | train |
rs/zerolog | diode/internal/diodes/waiter.go | Next | func (w *Waiter) Next() GenericDataType {
w.mu.Lock()
defer w.mu.Unlock()
for {
data, ok := w.Diode.TryNext()
if !ok {
if w.isDone() {
return nil
}
w.c.Wait()
continue
}
return data
}
} | go | func (w *Waiter) Next() GenericDataType {
w.mu.Lock()
defer w.mu.Unlock()
for {
data, ok := w.Diode.TryNext()
if !ok {
if w.isDone() {
return nil
}
w.c.Wait()
continue
}
return data
}
} | [
"func",
"(",
"w",
"*",
"Waiter",
")",
"Next",
"(",
")",
"GenericDataType",
"{",
"w",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"{",
"data",
",",
"ok",
":=",
"w",
".",
"Diode",
"."... | // Next returns the next data point on the wrapped diode. If there is not any
// new data, it will Wait for set to be called or the context to be done.
// If the context is done, then nil will be returned. | [
"Next",
"returns",
"the",
"next",
"data",
"point",
"on",
"the",
"wrapped",
"diode",
".",
"If",
"there",
"is",
"not",
"any",
"new",
"data",
"it",
"will",
"Wait",
"for",
"set",
"to",
"be",
"called",
"or",
"the",
"context",
"to",
"be",
"done",
".",
"If"... | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/diode/internal/diodes/waiter.go#L58-L74 | train |
rs/zerolog | internal/cbor/types.go | AppendNil | func (Encoder) AppendNil(dst []byte) []byte {
return append(dst, byte(majorTypeSimpleAndFloat|additionalTypeNull))
} | go | func (Encoder) AppendNil(dst []byte) []byte {
return append(dst, byte(majorTypeSimpleAndFloat|additionalTypeNull))
} | [
"func",
"(",
"Encoder",
")",
"AppendNil",
"(",
"dst",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"return",
"append",
"(",
"dst",
",",
"byte",
"(",
"majorTypeSimpleAndFloat",
"|",
"additionalTypeNull",
")",
")",
"\n",
"}"
] | // AppendNil inserts a 'Nil' object into the dst byte array. | [
"AppendNil",
"inserts",
"a",
"Nil",
"object",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L11-L13 | train |
rs/zerolog | internal/cbor/types.go | AppendBeginMarker | func (Encoder) AppendBeginMarker(dst []byte) []byte {
return append(dst, byte(majorTypeMap|additionalTypeInfiniteCount))
} | go | func (Encoder) AppendBeginMarker(dst []byte) []byte {
return append(dst, byte(majorTypeMap|additionalTypeInfiniteCount))
} | [
"func",
"(",
"Encoder",
")",
"AppendBeginMarker",
"(",
"dst",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"return",
"append",
"(",
"dst",
",",
"byte",
"(",
"majorTypeMap",
"|",
"additionalTypeInfiniteCount",
")",
")",
"\n",
"}"
] | // AppendBeginMarker inserts a map start into the dst byte array. | [
"AppendBeginMarker",
"inserts",
"a",
"map",
"start",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L16-L18 | train |
rs/zerolog | internal/cbor/types.go | AppendEndMarker | func (Encoder) AppendEndMarker(dst []byte) []byte {
return append(dst, byte(majorTypeSimpleAndFloat|additionalTypeBreak))
} | go | func (Encoder) AppendEndMarker(dst []byte) []byte {
return append(dst, byte(majorTypeSimpleAndFloat|additionalTypeBreak))
} | [
"func",
"(",
"Encoder",
")",
"AppendEndMarker",
"(",
"dst",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"return",
"append",
"(",
"dst",
",",
"byte",
"(",
"majorTypeSimpleAndFloat",
"|",
"additionalTypeBreak",
")",
")",
"\n",
"}"
] | // AppendEndMarker inserts a map end into the dst byte array. | [
"AppendEndMarker",
"inserts",
"a",
"map",
"end",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L21-L23 | train |
rs/zerolog | internal/cbor/types.go | AppendObjectData | func (Encoder) AppendObjectData(dst []byte, o []byte) []byte {
// BeginMarker is present in the dst, which
// should not be copied when appending to existing data.
return append(dst, o[1:]...)
} | go | func (Encoder) AppendObjectData(dst []byte, o []byte) []byte {
// BeginMarker is present in the dst, which
// should not be copied when appending to existing data.
return append(dst, o[1:]...)
} | [
"func",
"(",
"Encoder",
")",
"AppendObjectData",
"(",
"dst",
"[",
"]",
"byte",
",",
"o",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"// BeginMarker is present in the dst, which",
"// should not be copied when appending to existing data.",
"return",
"append",
"(",
... | // AppendObjectData takes an object in form of a byte array and appends to dst. | [
"AppendObjectData",
"takes",
"an",
"object",
"in",
"form",
"of",
"a",
"byte",
"array",
"and",
"appends",
"to",
"dst",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L26-L30 | train |
rs/zerolog | internal/cbor/types.go | AppendArrayStart | func (Encoder) AppendArrayStart(dst []byte) []byte {
return append(dst, byte(majorTypeArray|additionalTypeInfiniteCount))
} | go | func (Encoder) AppendArrayStart(dst []byte) []byte {
return append(dst, byte(majorTypeArray|additionalTypeInfiniteCount))
} | [
"func",
"(",
"Encoder",
")",
"AppendArrayStart",
"(",
"dst",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"return",
"append",
"(",
"dst",
",",
"byte",
"(",
"majorTypeArray",
"|",
"additionalTypeInfiniteCount",
")",
")",
"\n",
"}"
] | // AppendArrayStart adds markers to indicate the start of an array. | [
"AppendArrayStart",
"adds",
"markers",
"to",
"indicate",
"the",
"start",
"of",
"an",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L33-L35 | train |
rs/zerolog | internal/cbor/types.go | AppendArrayEnd | func (Encoder) AppendArrayEnd(dst []byte) []byte {
return append(dst, byte(majorTypeSimpleAndFloat|additionalTypeBreak))
} | go | func (Encoder) AppendArrayEnd(dst []byte) []byte {
return append(dst, byte(majorTypeSimpleAndFloat|additionalTypeBreak))
} | [
"func",
"(",
"Encoder",
")",
"AppendArrayEnd",
"(",
"dst",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"return",
"append",
"(",
"dst",
",",
"byte",
"(",
"majorTypeSimpleAndFloat",
"|",
"additionalTypeBreak",
")",
")",
"\n",
"}"
] | // AppendArrayEnd adds markers to indicate the end of an array. | [
"AppendArrayEnd",
"adds",
"markers",
"to",
"indicate",
"the",
"end",
"of",
"an",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L38-L40 | train |
rs/zerolog | internal/cbor/types.go | AppendBool | func (Encoder) AppendBool(dst []byte, val bool) []byte {
b := additionalTypeBoolFalse
if val {
b = additionalTypeBoolTrue
}
return append(dst, byte(majorTypeSimpleAndFloat|b))
} | go | func (Encoder) AppendBool(dst []byte, val bool) []byte {
b := additionalTypeBoolFalse
if val {
b = additionalTypeBoolTrue
}
return append(dst, byte(majorTypeSimpleAndFloat|b))
} | [
"func",
"(",
"Encoder",
")",
"AppendBool",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"bool",
")",
"[",
"]",
"byte",
"{",
"b",
":=",
"additionalTypeBoolFalse",
"\n",
"if",
"val",
"{",
"b",
"=",
"additionalTypeBoolTrue",
"\n",
"}",
"\n",
"return",
"appen... | // AppendBool encodes and inserts a boolean value into the dst byte array. | [
"AppendBool",
"encodes",
"and",
"inserts",
"a",
"boolean",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L55-L61 | train |
rs/zerolog | internal/cbor/types.go | AppendBools | func (e Encoder) AppendBools(dst []byte, vals []bool) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendBool(dst, v)
}
return dst
} | go | func (e Encoder) AppendBools(dst []byte, vals []bool) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendBool(dst, v)
}
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendBools",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"bool",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeArray",
"\n",
"l",
":=",
"len",
"(",
"vals",
")",
"\n",
"if",
"l",
"==",
"0",
"{"... | // AppendBools encodes and inserts an array of boolean values into the dst byte array. | [
"AppendBools",
"encodes",
"and",
"inserts",
"an",
"array",
"of",
"boolean",
"values",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L64-L80 | train |
rs/zerolog | internal/cbor/types.go | AppendInt | func (Encoder) AppendInt(dst []byte, val int) []byte {
major := majorTypeUnsignedInt
contentVal := val
if val < 0 {
major = majorTypeNegativeInt
contentVal = -val - 1
}
if contentVal <= additionalMax {
lb := byte(contentVal)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(contentVal))
}
return dst
} | go | func (Encoder) AppendInt(dst []byte, val int) []byte {
major := majorTypeUnsignedInt
contentVal := val
if val < 0 {
major = majorTypeNegativeInt
contentVal = -val - 1
}
if contentVal <= additionalMax {
lb := byte(contentVal)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(contentVal))
}
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendInt",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"int",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeUnsignedInt",
"\n",
"contentVal",
":=",
"val",
"\n",
"if",
"val",
"<",
"0",
"{",
"major",
"=",
"majorTypeN... | // AppendInt encodes and inserts an integer value into the dst byte array. | [
"AppendInt",
"encodes",
"and",
"inserts",
"an",
"integer",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L83-L97 | train |
rs/zerolog | internal/cbor/types.go | AppendInt8 | func (e Encoder) AppendInt8(dst []byte, val int8) []byte {
return e.AppendInt(dst, int(val))
} | go | func (e Encoder) AppendInt8(dst []byte, val int8) []byte {
return e.AppendInt(dst, int(val))
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendInt8",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"int8",
")",
"[",
"]",
"byte",
"{",
"return",
"e",
".",
"AppendInt",
"(",
"dst",
",",
"int",
"(",
"val",
")",
")",
"\n",
"}"
] | // AppendInt8 encodes and inserts an int8 value into the dst byte array. | [
"AppendInt8",
"encodes",
"and",
"inserts",
"an",
"int8",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L119-L121 | train |
rs/zerolog | internal/cbor/types.go | AppendInt16 | func (e Encoder) AppendInt16(dst []byte, val int16) []byte {
return e.AppendInt(dst, int(val))
} | go | func (e Encoder) AppendInt16(dst []byte, val int16) []byte {
return e.AppendInt(dst, int(val))
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendInt16",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"int16",
")",
"[",
"]",
"byte",
"{",
"return",
"e",
".",
"AppendInt",
"(",
"dst",
",",
"int",
"(",
"val",
")",
")",
"\n",
"}"
] | // AppendInt16 encodes and inserts a int16 value into the dst byte array. | [
"AppendInt16",
"encodes",
"and",
"inserts",
"a",
"int16",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L143-L145 | train |
rs/zerolog | internal/cbor/types.go | AppendInts16 | func (e Encoder) AppendInts16(dst []byte, vals []int16) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendInt(dst, int(v))
}
return dst
} | go | func (e Encoder) AppendInts16(dst []byte, vals []int16) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendInt(dst, int(v))
}
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendInts16",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"int16",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeArray",
"\n",
"l",
":=",
"len",
"(",
"vals",
")",
"\n",
"if",
"l",
"==",
"0",
"... | // AppendInts16 encodes and inserts an array of int16 values into the dst byte array. | [
"AppendInts16",
"encodes",
"and",
"inserts",
"an",
"array",
"of",
"int16",
"values",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L148-L164 | train |
rs/zerolog | internal/cbor/types.go | AppendInt32 | func (e Encoder) AppendInt32(dst []byte, val int32) []byte {
return e.AppendInt(dst, int(val))
} | go | func (e Encoder) AppendInt32(dst []byte, val int32) []byte {
return e.AppendInt(dst, int(val))
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendInt32",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"int32",
")",
"[",
"]",
"byte",
"{",
"return",
"e",
".",
"AppendInt",
"(",
"dst",
",",
"int",
"(",
"val",
")",
")",
"\n",
"}"
] | // AppendInt32 encodes and inserts a int32 value into the dst byte array. | [
"AppendInt32",
"encodes",
"and",
"inserts",
"a",
"int32",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L167-L169 | train |
rs/zerolog | internal/cbor/types.go | AppendInt64 | func (Encoder) AppendInt64(dst []byte, val int64) []byte {
major := majorTypeUnsignedInt
contentVal := val
if val < 0 {
major = majorTypeNegativeInt
contentVal = -val - 1
}
if contentVal <= additionalMax {
lb := byte(contentVal)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(contentVal))
}
return dst
} | go | func (Encoder) AppendInt64(dst []byte, val int64) []byte {
major := majorTypeUnsignedInt
contentVal := val
if val < 0 {
major = majorTypeNegativeInt
contentVal = -val - 1
}
if contentVal <= additionalMax {
lb := byte(contentVal)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(contentVal))
}
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendInt64",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"int64",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeUnsignedInt",
"\n",
"contentVal",
":=",
"val",
"\n",
"if",
"val",
"<",
"0",
"{",
"major",
"=",
"majorT... | // AppendInt64 encodes and inserts a int64 value into the dst byte array. | [
"AppendInt64",
"encodes",
"and",
"inserts",
"a",
"int64",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L191-L205 | train |
rs/zerolog | internal/cbor/types.go | AppendInts64 | func (e Encoder) AppendInts64(dst []byte, vals []int64) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendInt64(dst, v)
}
return dst
} | go | func (e Encoder) AppendInts64(dst []byte, vals []int64) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendInt64(dst, v)
}
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendInts64",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"int64",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeArray",
"\n",
"l",
":=",
"len",
"(",
"vals",
")",
"\n",
"if",
"l",
"==",
"0",
"... | // AppendInts64 encodes and inserts an array of int64 values into the dst byte array. | [
"AppendInts64",
"encodes",
"and",
"inserts",
"an",
"array",
"of",
"int64",
"values",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L208-L224 | train |
rs/zerolog | internal/cbor/types.go | AppendUint | func (e Encoder) AppendUint(dst []byte, val uint) []byte {
return e.AppendInt64(dst, int64(val))
} | go | func (e Encoder) AppendUint(dst []byte, val uint) []byte {
return e.AppendInt64(dst, int64(val))
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendUint",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"uint",
")",
"[",
"]",
"byte",
"{",
"return",
"e",
".",
"AppendInt64",
"(",
"dst",
",",
"int64",
"(",
"val",
")",
")",
"\n",
"}"
] | // AppendUint encodes and inserts an unsigned integer value into the dst byte array. | [
"AppendUint",
"encodes",
"and",
"inserts",
"an",
"unsigned",
"integer",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L227-L229 | train |
rs/zerolog | internal/cbor/types.go | AppendUints | func (e Encoder) AppendUints(dst []byte, vals []uint) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendUint(dst, v)
}
return dst
} | go | func (e Encoder) AppendUints(dst []byte, vals []uint) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendUint(dst, v)
}
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendUints",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"uint",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeArray",
"\n",
"l",
":=",
"len",
"(",
"vals",
")",
"\n",
"if",
"l",
"==",
"0",
"{"... | // AppendUints encodes and inserts an array of unsigned integer values into the dst byte array. | [
"AppendUints",
"encodes",
"and",
"inserts",
"an",
"array",
"of",
"unsigned",
"integer",
"values",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L232-L248 | train |
rs/zerolog | internal/cbor/types.go | AppendUint8 | func (e Encoder) AppendUint8(dst []byte, val uint8) []byte {
return e.AppendUint(dst, uint(val))
} | go | func (e Encoder) AppendUint8(dst []byte, val uint8) []byte {
return e.AppendUint(dst, uint(val))
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendUint8",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"uint8",
")",
"[",
"]",
"byte",
"{",
"return",
"e",
".",
"AppendUint",
"(",
"dst",
",",
"uint",
"(",
"val",
")",
")",
"\n",
"}"
] | // AppendUint8 encodes and inserts a unsigned int8 value into the dst byte array. | [
"AppendUint8",
"encodes",
"and",
"inserts",
"a",
"unsigned",
"int8",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L251-L253 | train |
rs/zerolog | internal/cbor/types.go | AppendUints8 | func (e Encoder) AppendUints8(dst []byte, vals []uint8) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendUint8(dst, v)
}
return dst
} | go | func (e Encoder) AppendUints8(dst []byte, vals []uint8) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendUint8(dst, v)
}
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendUints8",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"uint8",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeArray",
"\n",
"l",
":=",
"len",
"(",
"vals",
")",
"\n",
"if",
"l",
"==",
"0",
"... | // AppendUints8 encodes and inserts an array of uint8 values into the dst byte array. | [
"AppendUints8",
"encodes",
"and",
"inserts",
"an",
"array",
"of",
"uint8",
"values",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L256-L272 | train |
rs/zerolog | internal/cbor/types.go | AppendUint16 | func (e Encoder) AppendUint16(dst []byte, val uint16) []byte {
return e.AppendUint(dst, uint(val))
} | go | func (e Encoder) AppendUint16(dst []byte, val uint16) []byte {
return e.AppendUint(dst, uint(val))
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendUint16",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"uint16",
")",
"[",
"]",
"byte",
"{",
"return",
"e",
".",
"AppendUint",
"(",
"dst",
",",
"uint",
"(",
"val",
")",
")",
"\n",
"}"
] | // AppendUint16 encodes and inserts a uint16 value into the dst byte array. | [
"AppendUint16",
"encodes",
"and",
"inserts",
"a",
"uint16",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L275-L277 | train |
rs/zerolog | internal/cbor/types.go | AppendUints16 | func (e Encoder) AppendUints16(dst []byte, vals []uint16) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendUint16(dst, v)
}
return dst
} | go | func (e Encoder) AppendUints16(dst []byte, vals []uint16) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendUint16(dst, v)
}
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendUints16",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"uint16",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeArray",
"\n",
"l",
":=",
"len",
"(",
"vals",
")",
"\n",
"if",
"l",
"==",
"0",
... | // AppendUints16 encodes and inserts an array of uint16 values into the dst byte array. | [
"AppendUints16",
"encodes",
"and",
"inserts",
"an",
"array",
"of",
"uint16",
"values",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L280-L296 | train |
rs/zerolog | internal/cbor/types.go | AppendUint32 | func (e Encoder) AppendUint32(dst []byte, val uint32) []byte {
return e.AppendUint(dst, uint(val))
} | go | func (e Encoder) AppendUint32(dst []byte, val uint32) []byte {
return e.AppendUint(dst, uint(val))
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendUint32",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"uint32",
")",
"[",
"]",
"byte",
"{",
"return",
"e",
".",
"AppendUint",
"(",
"dst",
",",
"uint",
"(",
"val",
")",
")",
"\n",
"}"
] | // AppendUint32 encodes and inserts a uint32 value into the dst byte array. | [
"AppendUint32",
"encodes",
"and",
"inserts",
"a",
"uint32",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L299-L301 | train |
rs/zerolog | internal/cbor/types.go | AppendUints32 | func (e Encoder) AppendUints32(dst []byte, vals []uint32) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendUint32(dst, v)
}
return dst
} | go | func (e Encoder) AppendUints32(dst []byte, vals []uint32) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendUint32(dst, v)
}
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendUints32",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"uint32",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeArray",
"\n",
"l",
":=",
"len",
"(",
"vals",
")",
"\n",
"if",
"l",
"==",
"0",
... | // AppendUints32 encodes and inserts an array of uint32 values into the dst byte array. | [
"AppendUints32",
"encodes",
"and",
"inserts",
"an",
"array",
"of",
"uint32",
"values",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L304-L320 | train |
rs/zerolog | internal/cbor/types.go | AppendUint64 | func (Encoder) AppendUint64(dst []byte, val uint64) []byte {
major := majorTypeUnsignedInt
contentVal := val
if contentVal <= additionalMax {
lb := byte(contentVal)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(contentVal))
}
return dst
} | go | func (Encoder) AppendUint64(dst []byte, val uint64) []byte {
major := majorTypeUnsignedInt
contentVal := val
if contentVal <= additionalMax {
lb := byte(contentVal)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(contentVal))
}
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendUint64",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"uint64",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeUnsignedInt",
"\n",
"contentVal",
":=",
"val",
"\n",
"if",
"contentVal",
"<=",
"additionalMax",
"{",
"lb... | // AppendUint64 encodes and inserts a uint64 value into the dst byte array. | [
"AppendUint64",
"encodes",
"and",
"inserts",
"a",
"uint64",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L323-L333 | train |
rs/zerolog | internal/cbor/types.go | AppendUints64 | func (e Encoder) AppendUints64(dst []byte, vals []uint64) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendUint64(dst, v)
}
return dst
} | go | func (e Encoder) AppendUints64(dst []byte, vals []uint64) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendUint64(dst, v)
}
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendUints64",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"uint64",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeArray",
"\n",
"l",
":=",
"len",
"(",
"vals",
")",
"\n",
"if",
"l",
"==",
"0",
... | // AppendUints64 encodes and inserts an array of uint64 values into the dst byte array. | [
"AppendUints64",
"encodes",
"and",
"inserts",
"an",
"array",
"of",
"uint64",
"values",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L336-L352 | train |
rs/zerolog | internal/cbor/types.go | AppendFloat32 | func (Encoder) AppendFloat32(dst []byte, val float32) []byte {
switch {
case math.IsNaN(float64(val)):
return append(dst, "\xfa\x7f\xc0\x00\x00"...)
case math.IsInf(float64(val), 1):
return append(dst, "\xfa\x7f\x80\x00\x00"...)
case math.IsInf(float64(val), -1):
return append(dst, "\xfa\xff\x80\x00\x00"...)
}
major := majorTypeSimpleAndFloat
subType := additionalTypeFloat32
n := math.Float32bits(val)
var buf [4]byte
for i := uint(0); i < 4; i++ {
buf[i] = byte(n >> ((3 - i) * 8))
}
return append(append(dst, byte(major|subType)), buf[0], buf[1], buf[2], buf[3])
} | go | func (Encoder) AppendFloat32(dst []byte, val float32) []byte {
switch {
case math.IsNaN(float64(val)):
return append(dst, "\xfa\x7f\xc0\x00\x00"...)
case math.IsInf(float64(val), 1):
return append(dst, "\xfa\x7f\x80\x00\x00"...)
case math.IsInf(float64(val), -1):
return append(dst, "\xfa\xff\x80\x00\x00"...)
}
major := majorTypeSimpleAndFloat
subType := additionalTypeFloat32
n := math.Float32bits(val)
var buf [4]byte
for i := uint(0); i < 4; i++ {
buf[i] = byte(n >> ((3 - i) * 8))
}
return append(append(dst, byte(major|subType)), buf[0], buf[1], buf[2], buf[3])
} | [
"func",
"(",
"Encoder",
")",
"AppendFloat32",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"float32",
")",
"[",
"]",
"byte",
"{",
"switch",
"{",
"case",
"math",
".",
"IsNaN",
"(",
"float64",
"(",
"val",
")",
")",
":",
"return",
"append",
"(",
"dst",
... | // AppendFloat32 encodes and inserts a single precision float value into the dst byte array. | [
"AppendFloat32",
"encodes",
"and",
"inserts",
"a",
"single",
"precision",
"float",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L355-L372 | train |
rs/zerolog | internal/cbor/types.go | AppendFloats32 | func (e Encoder) AppendFloats32(dst []byte, vals []float32) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendFloat32(dst, v)
}
return dst
} | go | func (e Encoder) AppendFloats32(dst []byte, vals []float32) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendFloat32(dst, v)
}
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendFloats32",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"float32",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeArray",
"\n",
"l",
":=",
"len",
"(",
"vals",
")",
"\n",
"if",
"l",
"==",
"0",... | // AppendFloats32 encodes and inserts an array of single precision float value into the dst byte array. | [
"AppendFloats32",
"encodes",
"and",
"inserts",
"an",
"array",
"of",
"single",
"precision",
"float",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L375-L391 | train |
rs/zerolog | internal/cbor/types.go | AppendFloat64 | func (Encoder) AppendFloat64(dst []byte, val float64) []byte {
switch {
case math.IsNaN(val):
return append(dst, "\xfb\x7f\xf8\x00\x00\x00\x00\x00\x00"...)
case math.IsInf(val, 1):
return append(dst, "\xfb\x7f\xf0\x00\x00\x00\x00\x00\x00"...)
case math.IsInf(val, -1):
return append(dst, "\xfb\xff\xf0\x00\x00\x00\x00\x00\x00"...)
}
major := majorTypeSimpleAndFloat
subType := additionalTypeFloat64
n := math.Float64bits(val)
dst = append(dst, byte(major|subType))
for i := uint(1); i <= 8; i++ {
b := byte(n >> ((8 - i) * 8))
dst = append(dst, b)
}
return dst
} | go | func (Encoder) AppendFloat64(dst []byte, val float64) []byte {
switch {
case math.IsNaN(val):
return append(dst, "\xfb\x7f\xf8\x00\x00\x00\x00\x00\x00"...)
case math.IsInf(val, 1):
return append(dst, "\xfb\x7f\xf0\x00\x00\x00\x00\x00\x00"...)
case math.IsInf(val, -1):
return append(dst, "\xfb\xff\xf0\x00\x00\x00\x00\x00\x00"...)
}
major := majorTypeSimpleAndFloat
subType := additionalTypeFloat64
n := math.Float64bits(val)
dst = append(dst, byte(major|subType))
for i := uint(1); i <= 8; i++ {
b := byte(n >> ((8 - i) * 8))
dst = append(dst, b)
}
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendFloat64",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"float64",
")",
"[",
"]",
"byte",
"{",
"switch",
"{",
"case",
"math",
".",
"IsNaN",
"(",
"val",
")",
":",
"return",
"append",
"(",
"dst",
",",
"\"",
"\\xfb",
... | // AppendFloat64 encodes and inserts a double precision float value into the dst byte array. | [
"AppendFloat64",
"encodes",
"and",
"inserts",
"a",
"double",
"precision",
"float",
"value",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L394-L412 | train |
rs/zerolog | internal/cbor/types.go | AppendFloats64 | func (e Encoder) AppendFloats64(dst []byte, vals []float64) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendFloat64(dst, v)
}
return dst
} | go | func (e Encoder) AppendFloats64(dst []byte, vals []float64) []byte {
major := majorTypeArray
l := len(vals)
if l == 0 {
return e.AppendArrayEnd(e.AppendArrayStart(dst))
}
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendFloat64(dst, v)
}
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendFloats64",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"float64",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeArray",
"\n",
"l",
":=",
"len",
"(",
"vals",
")",
"\n",
"if",
"l",
"==",
"0",... | // AppendFloats64 encodes and inserts an array of double precision float values into the dst byte array. | [
"AppendFloats64",
"encodes",
"and",
"inserts",
"an",
"array",
"of",
"double",
"precision",
"float",
"values",
"into",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L415-L431 | train |
rs/zerolog | internal/cbor/types.go | AppendInterface | func (e Encoder) AppendInterface(dst []byte, i interface{}) []byte {
marshaled, err := json.Marshal(i)
if err != nil {
return e.AppendString(dst, fmt.Sprintf("marshaling error: %v", err))
}
return AppendEmbeddedJSON(dst, marshaled)
} | go | func (e Encoder) AppendInterface(dst []byte, i interface{}) []byte {
marshaled, err := json.Marshal(i)
if err != nil {
return e.AppendString(dst, fmt.Sprintf("marshaling error: %v", err))
}
return AppendEmbeddedJSON(dst, marshaled)
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendInterface",
"(",
"dst",
"[",
"]",
"byte",
",",
"i",
"interface",
"{",
"}",
")",
"[",
"]",
"byte",
"{",
"marshaled",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"i",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // AppendInterface takes an arbitrary object and converts it to JSON and embeds it dst. | [
"AppendInterface",
"takes",
"an",
"arbitrary",
"object",
"and",
"converts",
"it",
"to",
"JSON",
"and",
"embeds",
"it",
"dst",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L434-L440 | train |
rs/zerolog | internal/cbor/types.go | AppendHex | func (e Encoder) AppendHex(dst []byte, val []byte) []byte {
dst = append(dst, byte(majorTypeTags|additionalTypeIntUint16))
dst = append(dst, byte(additionalTypeTagHexString>>8))
dst = append(dst, byte(additionalTypeTagHexString&0xff))
return e.AppendBytes(dst, val)
} | go | func (e Encoder) AppendHex(dst []byte, val []byte) []byte {
dst = append(dst, byte(majorTypeTags|additionalTypeIntUint16))
dst = append(dst, byte(additionalTypeTagHexString>>8))
dst = append(dst, byte(additionalTypeTagHexString&0xff))
return e.AppendBytes(dst, val)
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendHex",
"(",
"dst",
"[",
"]",
"byte",
",",
"val",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"dst",
"=",
"append",
"(",
"dst",
",",
"byte",
"(",
"majorTypeTags",
"|",
"additionalTypeIntUint16",
")",
")",
"\... | // AppendHex adds a TAG and inserts a hex bytes as a string. | [
"AppendHex",
"adds",
"a",
"TAG",
"and",
"inserts",
"a",
"hex",
"bytes",
"as",
"a",
"string",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/types.go#L473-L478 | train |
rs/zerolog | writer.go | WriteLevel | func (s *syncWriter) WriteLevel(l Level, p []byte) (n int, err error) {
s.mu.Lock()
defer s.mu.Unlock()
return s.lw.WriteLevel(l, p)
} | go | func (s *syncWriter) WriteLevel(l Level, p []byte) (n int, err error) {
s.mu.Lock()
defer s.mu.Unlock()
return s.lw.WriteLevel(l, p)
} | [
"func",
"(",
"s",
"*",
"syncWriter",
")",
"WriteLevel",
"(",
"l",
"Level",
",",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
... | // WriteLevel implements the LevelWriter interface. | [
"WriteLevel",
"implements",
"the",
"LevelWriter",
"interface",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/writer.go#L49-L53 | train |
rs/zerolog | internal/cbor/string.go | AppendStrings | func (e Encoder) AppendStrings(dst []byte, vals []string) []byte {
major := majorTypeArray
l := len(vals)
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendString(dst, v)
}
return dst
} | go | func (e Encoder) AppendStrings(dst []byte, vals []string) []byte {
major := majorTypeArray
l := len(vals)
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
for _, v := range vals {
dst = e.AppendString(dst, v)
}
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendStrings",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"string",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeArray",
"\n",
"l",
":=",
"len",
"(",
"vals",
")",
"\n",
"if",
"l",
"<=",
"addit... | // AppendStrings encodes and adds an array of strings to the dst byte array. | [
"AppendStrings",
"encodes",
"and",
"adds",
"an",
"array",
"of",
"strings",
"to",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/string.go#L4-L17 | train |
rs/zerolog | internal/cbor/string.go | AppendString | func (Encoder) AppendString(dst []byte, s string) []byte {
major := majorTypeUtf8String
l := len(s)
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, majorTypeUtf8String, uint64(l))
}
return append(dst, s...)
} | go | func (Encoder) AppendString(dst []byte, s string) []byte {
major := majorTypeUtf8String
l := len(s)
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, majorTypeUtf8String, uint64(l))
}
return append(dst, s...)
} | [
"func",
"(",
"Encoder",
")",
"AppendString",
"(",
"dst",
"[",
"]",
"byte",
",",
"s",
"string",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeUtf8String",
"\n\n",
"l",
":=",
"len",
"(",
"s",
")",
"\n",
"if",
"l",
"<=",
"additionalMax",
"{",
"... | // AppendString encodes and adds a string to the dst byte array. | [
"AppendString",
"encodes",
"and",
"adds",
"a",
"string",
"to",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/string.go#L20-L31 | train |
rs/zerolog | internal/cbor/string.go | AppendBytes | func (Encoder) AppendBytes(dst, s []byte) []byte {
major := majorTypeByteString
l := len(s)
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
return append(dst, s...)
} | go | func (Encoder) AppendBytes(dst, s []byte) []byte {
major := majorTypeByteString
l := len(s)
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
return append(dst, s...)
} | [
"func",
"(",
"Encoder",
")",
"AppendBytes",
"(",
"dst",
",",
"s",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeByteString",
"\n\n",
"l",
":=",
"len",
"(",
"s",
")",
"\n",
"if",
"l",
"<=",
"additionalMax",
"{",
"lb",
":=",
... | // AppendBytes encodes and adds an array of bytes to the dst byte array. | [
"AppendBytes",
"encodes",
"and",
"adds",
"an",
"array",
"of",
"bytes",
"to",
"the",
"dst",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/string.go#L34-L45 | train |
rs/zerolog | internal/cbor/string.go | AppendEmbeddedJSON | func AppendEmbeddedJSON(dst, s []byte) []byte {
major := majorTypeTags
minor := additionalTypeEmbeddedJSON
// Append the TAG to indicate this is Embedded JSON.
dst = append(dst, byte(major|additionalTypeIntUint16))
dst = append(dst, byte(minor>>8))
dst = append(dst, byte(minor&0xff))
// Append the JSON Object as Byte String.
major = majorTypeByteString
l := len(s)
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
return append(dst, s...)
} | go | func AppendEmbeddedJSON(dst, s []byte) []byte {
major := majorTypeTags
minor := additionalTypeEmbeddedJSON
// Append the TAG to indicate this is Embedded JSON.
dst = append(dst, byte(major|additionalTypeIntUint16))
dst = append(dst, byte(minor>>8))
dst = append(dst, byte(minor&0xff))
// Append the JSON Object as Byte String.
major = majorTypeByteString
l := len(s)
if l <= additionalMax {
lb := byte(l)
dst = append(dst, byte(major|lb))
} else {
dst = appendCborTypePrefix(dst, major, uint64(l))
}
return append(dst, s...)
} | [
"func",
"AppendEmbeddedJSON",
"(",
"dst",
",",
"s",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"major",
":=",
"majorTypeTags",
"\n",
"minor",
":=",
"additionalTypeEmbeddedJSON",
"\n\n",
"// Append the TAG to indicate this is Embedded JSON.",
"dst",
"=",
"append",... | // AppendEmbeddedJSON adds a tag and embeds input JSON as such. | [
"AppendEmbeddedJSON",
"adds",
"a",
"tag",
"and",
"embeds",
"input",
"JSON",
"as",
"such",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/string.go#L48-L68 | train |
rs/zerolog | ctx.go | Ctx | func Ctx(ctx context.Context) *Logger {
if l, ok := ctx.Value(ctxKey{}).(*Logger); ok {
return l
}
return disabledLogger
} | go | func Ctx(ctx context.Context) *Logger {
if l, ok := ctx.Value(ctxKey{}).(*Logger); ok {
return l
}
return disabledLogger
} | [
"func",
"Ctx",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"Logger",
"{",
"if",
"l",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKey",
"{",
"}",
")",
".",
"(",
"*",
"Logger",
")",
";",
"ok",
"{",
"return",
"l",
"\n",
"}",
"\n",
"retur... | // Ctx returns the Logger associated with the ctx. If no logger
// is associated, a disabled logger is returned. | [
"Ctx",
"returns",
"the",
"Logger",
"associated",
"with",
"the",
"ctx",
".",
"If",
"no",
"logger",
"is",
"associated",
"a",
"disabled",
"logger",
"is",
"returned",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/ctx.go#L42-L47 | train |
rs/zerolog | internal/cbor/decode_stream.go | DecodeObjectToStr | func DecodeObjectToStr(in []byte) string {
if binaryFmt(in) {
var b bytes.Buffer
cbor2JsonOneObject(getReader(string(in)), &b)
return b.String()
}
return string(in)
} | go | func DecodeObjectToStr(in []byte) string {
if binaryFmt(in) {
var b bytes.Buffer
cbor2JsonOneObject(getReader(string(in)), &b)
return b.String()
}
return string(in)
} | [
"func",
"DecodeObjectToStr",
"(",
"in",
"[",
"]",
"byte",
")",
"string",
"{",
"if",
"binaryFmt",
"(",
"in",
")",
"{",
"var",
"b",
"bytes",
".",
"Buffer",
"\n",
"cbor2JsonOneObject",
"(",
"getReader",
"(",
"string",
"(",
"in",
")",
")",
",",
"&",
"b",... | // DecodeObjectToStr checks if the input is a binary format, if so,
// it will decode a single Object and return the decoded string. | [
"DecodeObjectToStr",
"checks",
"if",
"the",
"input",
"is",
"a",
"binary",
"format",
"if",
"so",
"it",
"will",
"decode",
"a",
"single",
"Object",
"and",
"return",
"the",
"decoded",
"string",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/decode_stream.go#L596-L603 | train |
rs/zerolog | internal/cbor/decode_stream.go | DecodeIfBinaryToBytes | func DecodeIfBinaryToBytes(in []byte) []byte {
if binaryFmt(in) {
var b bytes.Buffer
Cbor2JsonManyObjects(bytes.NewReader(in), &b)
return b.Bytes()
}
return in
} | go | func DecodeIfBinaryToBytes(in []byte) []byte {
if binaryFmt(in) {
var b bytes.Buffer
Cbor2JsonManyObjects(bytes.NewReader(in), &b)
return b.Bytes()
}
return in
} | [
"func",
"DecodeIfBinaryToBytes",
"(",
"in",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"if",
"binaryFmt",
"(",
"in",
")",
"{",
"var",
"b",
"bytes",
".",
"Buffer",
"\n",
"Cbor2JsonManyObjects",
"(",
"bytes",
".",
"NewReader",
"(",
"in",
")",
",",
"... | // DecodeIfBinaryToBytes checks if the input is a binary format, if so,
// it will decode all Objects and return the decoded string as byte array. | [
"DecodeIfBinaryToBytes",
"checks",
"if",
"the",
"input",
"is",
"a",
"binary",
"format",
"if",
"so",
"it",
"will",
"decode",
"all",
"Objects",
"and",
"return",
"the",
"decoded",
"string",
"as",
"byte",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/decode_stream.go#L607-L614 | train |
rs/zerolog | cmd/lint/lint.go | init | func init() {
flag.Var(&recursivelyIgnoredPkgs, "ignorePkgRecursively", "ignore the specified package and all subpackages recursively")
flag.Var(&ignoredPkgs, "ignorePkg", "ignore the specified package")
flag.Var(&ignoredFiles, "ignoreFile", "ignore the specified file by its path and/or go path (package/file.go)")
flag.Var(&allowedFinishers, "finisher", "allowed finisher for the event chain")
flag.Parse()
// add zerolog to recursively ignored packages
recursivelyIgnoredPkgs = append(recursivelyIgnoredPkgs, "github.com/rs/zerolog")
args := flag.Args()
if len(args) != 1 {
fmt.Fprintln(os.Stderr, "you must provide exactly one package path")
os.Exit(1)
}
rootPkg = args[0]
} | go | func init() {
flag.Var(&recursivelyIgnoredPkgs, "ignorePkgRecursively", "ignore the specified package and all subpackages recursively")
flag.Var(&ignoredPkgs, "ignorePkg", "ignore the specified package")
flag.Var(&ignoredFiles, "ignoreFile", "ignore the specified file by its path and/or go path (package/file.go)")
flag.Var(&allowedFinishers, "finisher", "allowed finisher for the event chain")
flag.Parse()
// add zerolog to recursively ignored packages
recursivelyIgnoredPkgs = append(recursivelyIgnoredPkgs, "github.com/rs/zerolog")
args := flag.Args()
if len(args) != 1 {
fmt.Fprintln(os.Stderr, "you must provide exactly one package path")
os.Exit(1)
}
rootPkg = args[0]
} | [
"func",
"init",
"(",
")",
"{",
"flag",
".",
"Var",
"(",
"&",
"recursivelyIgnoredPkgs",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flag",
".",
"Var",
"(",
"&",
"ignoredPkgs",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"flag",
".",
"Var",
"(... | // parse input flags and args | [
"parse",
"input",
"flags",
"and",
"args"
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/cmd/lint/lint.go#L25-L40 | train |
rs/zerolog | diode/diode.go | Close | func (dw Writer) Close() error {
dw.c()
<-dw.done
if w, ok := dw.w.(io.Closer); ok {
return w.Close()
}
return nil
} | go | func (dw Writer) Close() error {
dw.c()
<-dw.done
if w, ok := dw.w.(io.Closer); ok {
return w.Close()
}
return nil
} | [
"func",
"(",
"dw",
"Writer",
")",
"Close",
"(",
")",
"error",
"{",
"dw",
".",
"c",
"(",
")",
"\n",
"<-",
"dw",
".",
"done",
"\n",
"if",
"w",
",",
"ok",
":=",
"dw",
".",
"w",
".",
"(",
"io",
".",
"Closer",
")",
";",
"ok",
"{",
"return",
"w... | // Close releases the diode poller and call Close on the wrapped writer if
// io.Closer is implemented. | [
"Close",
"releases",
"the",
"diode",
"poller",
"and",
"call",
"Close",
"on",
"the",
"wrapped",
"writer",
"if",
"io",
".",
"Closer",
"is",
"implemented",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/diode/diode.go#L84-L91 | train |
rs/zerolog | context.go | Dict | func (c Context) Dict(key string, dict *Event) Context {
dict.buf = enc.AppendEndMarker(dict.buf)
c.l.context = append(enc.AppendKey(c.l.context, key), dict.buf...)
putEvent(dict)
return c
} | go | func (c Context) Dict(key string, dict *Event) Context {
dict.buf = enc.AppendEndMarker(dict.buf)
c.l.context = append(enc.AppendKey(c.l.context, key), dict.buf...)
putEvent(dict)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Dict",
"(",
"key",
"string",
",",
"dict",
"*",
"Event",
")",
"Context",
"{",
"dict",
".",
"buf",
"=",
"enc",
".",
"AppendEndMarker",
"(",
"dict",
".",
"buf",
")",
"\n",
"c",
".",
"l",
".",
"context",
"=",
"appen... | // Dict adds the field key with the dict to the logger context. | [
"Dict",
"adds",
"the",
"field",
"key",
"with",
"the",
"dict",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L27-L32 | train |
rs/zerolog | context.go | EmbedObject | func (c Context) EmbedObject(obj LogObjectMarshaler) Context {
e := newEvent(levelWriterAdapter{ioutil.Discard}, 0)
e.EmbedObject(obj)
c.l.context = enc.AppendObjectData(c.l.context, e.buf)
putEvent(e)
return c
} | go | func (c Context) EmbedObject(obj LogObjectMarshaler) Context {
e := newEvent(levelWriterAdapter{ioutil.Discard}, 0)
e.EmbedObject(obj)
c.l.context = enc.AppendObjectData(c.l.context, e.buf)
putEvent(e)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"EmbedObject",
"(",
"obj",
"LogObjectMarshaler",
")",
"Context",
"{",
"e",
":=",
"newEvent",
"(",
"levelWriterAdapter",
"{",
"ioutil",
".",
"Discard",
"}",
",",
"0",
")",
"\n",
"e",
".",
"EmbedObject",
"(",
"obj",
")",
... | // EmbedObject marshals and Embeds an object that implement the LogObjectMarshaler interface. | [
"EmbedObject",
"marshals",
"and",
"Embeds",
"an",
"object",
"that",
"implement",
"the",
"LogObjectMarshaler",
"interface",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L64-L70 | train |
rs/zerolog | context.go | Str | func (c Context) Str(key, val string) Context {
c.l.context = enc.AppendString(enc.AppendKey(c.l.context, key), val)
return c
} | go | func (c Context) Str(key, val string) Context {
c.l.context = enc.AppendString(enc.AppendKey(c.l.context, key), val)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Str",
"(",
"key",
",",
"val",
"string",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendString",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"key",
")",
"... | // Str adds the field key with val as a string to the logger context. | [
"Str",
"adds",
"the",
"field",
"key",
"with",
"val",
"as",
"a",
"string",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L73-L76 | train |
rs/zerolog | context.go | Strs | func (c Context) Strs(key string, vals []string) Context {
c.l.context = enc.AppendStrings(enc.AppendKey(c.l.context, key), vals)
return c
} | go | func (c Context) Strs(key string, vals []string) Context {
c.l.context = enc.AppendStrings(enc.AppendKey(c.l.context, key), vals)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Strs",
"(",
"key",
"string",
",",
"vals",
"[",
"]",
"string",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendStrings",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context... | // Strs adds the field key with val as a string to the logger context. | [
"Strs",
"adds",
"the",
"field",
"key",
"with",
"val",
"as",
"a",
"string",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L79-L82 | train |
rs/zerolog | context.go | Hex | func (c Context) Hex(key string, val []byte) Context {
c.l.context = enc.AppendHex(enc.AppendKey(c.l.context, key), val)
return c
} | go | func (c Context) Hex(key string, val []byte) Context {
c.l.context = enc.AppendHex(enc.AppendKey(c.l.context, key), val)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Hex",
"(",
"key",
"string",
",",
"val",
"[",
"]",
"byte",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendHex",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
","... | // Hex adds the field key with val as a hex string to the logger context. | [
"Hex",
"adds",
"the",
"field",
"key",
"with",
"val",
"as",
"a",
"hex",
"string",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L91-L94 | train |
rs/zerolog | context.go | RawJSON | func (c Context) RawJSON(key string, b []byte) Context {
c.l.context = appendJSON(enc.AppendKey(c.l.context, key), b)
return c
} | go | func (c Context) RawJSON(key string, b []byte) Context {
c.l.context = appendJSON(enc.AppendKey(c.l.context, key), b)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"RawJSON",
"(",
"key",
"string",
",",
"b",
"[",
"]",
"byte",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"appendJSON",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"key",
... | // RawJSON adds already encoded JSON to context.
//
// No sanity check is performed on b; it must not contain carriage returns and
// be valid JSON. | [
"RawJSON",
"adds",
"already",
"encoded",
"JSON",
"to",
"context",
".",
"No",
"sanity",
"check",
"is",
"performed",
"on",
"b",
";",
"it",
"must",
"not",
"contain",
"carriage",
"returns",
"and",
"be",
"valid",
"JSON",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L100-L103 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.