Documentation ¶
Index ¶
Constants ¶
const Is64Bit = math.MaxInt64 == math.MaxInt
Is64Bit is true on 64-bit systems. (In 2022, that's nearly everything).
Variables ¶
This section is empty.
Functions ¶
func ThisFileLine ¶
func TrimFunction ¶
TrimFunction trims a function path containing "efronlicht/estd", making it start with "estd". EG, "users/efron/go/src/gitlab.com/efronlicht/estd/parse/IPv4" => "estd/parse.IPv4". this looks nice, but has a runtime cost. use the build tag "eruntime_notrim" to disable it
Types ¶
type FuncInfo ¶
type FuncInfo struct { // Function name, obtained via runtime.FuncForPC.Name(). Function string // Filename, including path. File string Label string // optional label Line int }
FuncInfo is limited function metadata, often embedded in logs. It has a handy String() which looks like this: Get a FuncInfo with NamedFunc() or Caller().
func Caller ¶
Caller reports the file, line number, and name of the function skip levels up the stack. skip=0 is the caller of Caller:
func a() { return fmt.Println(Caller(1))} func b() { a() } // will print info about b(), not a().
func LabeledCaller ¶
func (*FuncInfo) MarshalLogObject ¶
func (fi *FuncInfo) MarshalLogObject(oe zapcore.ObjectEncoder) error
func (*FuncInfo) MarshalZerologObject ¶
type StackSlice ¶
type StackSlice []*FuncInfo
StackSlice is a []*FuncInfo that nicely formats for fmt.Stringer, zapcore.ArrayMarshaler, and zerolog.ZerologArrayMarshaler.
func Callers ¶
func Callers(skip, n int) (callers StackSlice)
Callers obtains a miniature stack trace of at most n elements starting at skip via runtime.Callers(skip+1). It returns at most n elements, but may return fewer, or even zero (if skip is larger than the stack).
func (StackSlice) MarshalLogArray ¶
func (s StackSlice) MarshalLogArray(ae zapcore.ArrayEncoder) error
func (StackSlice) MarshalZerologArray ¶
func (s StackSlice) MarshalZerologArray(a *zerolog.Array)
func (StackSlice) String ¶
func (s StackSlice) String() string