util/log/logger.go
func (l *LoggerBase) Add(vars ...interface{}) Logger {
	if len(vars)%2 == 1 {
		panic("bad number of arguments")
	}

	ctx := map[string]interface{}{}

	for k, v := range l.ctx {
		ctx[k] = v
	}

	num := len(vars) / 2
	for i := 0; i < num; i++ {
		name, ok := vars[i*2].(string)
		if !ok {
			panic("non-string variable name")
		}
		ctx[name] = vars[i*2+1]
	}

	return &LoggerBase{conf: l.conf, log: l.log, ctx: ctx}
}
func (l *LoggerBase) Add(vars ...interface{}) Logger {
	if len(vars)%2 == 1 {
		panic("bad number of arguments")
	}

	ctx := map[string]interface{}{}

	for k, v := range l.ctx {
		ctx[k] = v
	}

	num := len(vars) / 2
	for i := 0; i < num; i++ {
		name, ok := vars[i*2].(string)
		if !ok {
			panic("non-string variable name")
		}
		ctx[name] = vars[i*2+1]
	}

	return &LoggerBase{conf: l.conf, log: l.log, ctx: ctx}
}
func ( l * LoggerBase ) Add ( vars ... interface { } ) Logger { if len ( vars ) % 2 == 1 { panic ( " " ) } ctx := map [ string ] interface { } { } for k , v := range l . ctx { ctx [ k ] = v } num := len ( vars ) / 2 for i := 0 ; i < num ; i ++ { name , ok := vars [ i * 2 ] . ( string ) if ! ok { panic ( " " ) } ctx [ name ] = vars [ i * 2 + 1 ] } return & LoggerBase { conf : l . conf , log : l . log , ctx : ctx } }
// Add returns a new logger with added context variables. This function takes
// alternated key-value pairs (name1, val1, name1, val2, ...). The keys must be
// strings, but the values can be of any type.
Add returns a new logger with added context variables . This function takes alternated key - value pairs ( name1 val1 name1 val2 ... ) . The keys must be strings but the values can be of any type .