1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
12 // Log calls log.Println but first transforms strings so they are
13 // safer to write in logs (e.g., 'foo"bar' becomes
14 // '"foo\"bar"'). Arguments that aren't strings and don't have a
15 // (String() string) method are left alone.
16 func Log(args ...interface{}) {
17 newargs := make([]interface{}, len(args))
18 for i, arg := range args {
19 if s, ok := arg.(string); ok {
20 newargs[i] = fmt.Sprintf("%+q", s)
21 } else if s, ok := arg.(fmt.Stringer); ok {
22 newargs[i] = fmt.Sprintf("%+q", s.String())
27 log.Println(newargs...)