func trimCallerPath(path string) string {
	idx := strings.LastIndexByte(path, '/')
	if idx == -1 {
		return path
	}
	idx = strings.LastIndexByte(path[:idx], '/')
	if idx == -1 {
		return path
	}
	return path[idx+1:]
}
Cleanup a path by returning the last 2 segments of the path only.
package hclog
import (
	"bytes"
	"encoding"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"log"
	"os"
	"reflect"
	"regexp"
	"runtime"
	"sort"
	"strconv"
	"strings"
	"sync"
	"sync/atomic"
	"time"
	"github.com/fatih/color"
)
const TimeFormat = "2006-01-02T15:04:05.000Z0700"
const errJsonUnsupportedTypeMsg = "logging contained values that don't serialize to json"
var (
	_levelToBracket = map[Level]string{
		Debug: "[DEBUG]",
		Trace: "[TRACE]",
		Info:  "[INFO] ",
		Warn:  "[WARN] ",
		Error: "[ERROR]",
	}
	_levelToColor = map[Level]*color.Color{
		Debug: color.New(color.FgHiWhite),
		Trace: color.New(color.FgHiGreen),
		Info:  color.New(color.FgHiBlue),
		Warn:  color.New(color.FgHiYellow),
		Error: color.New(color.FgHiRed),
	}
)
var _ Logger = &intLogger{}
type intLogger struct {
	json       bool
	caller     bool
	name       string
	timeFormat string
	mutex  Locker
	writer *writer
	level  *int32
	implied []interface{}
	exclude func(level Level, msg string, args ...interface{}) bool
}
func New(opts *LoggerOptions) Logger {
	return newLogger(opts)
}
func NewSinkAdapter(opts *LoggerOptions) SinkAdapter {
	return newLogger(opts)
}
func newLogger(opts *LoggerOptions) *intLogger {
	if opts == nil {
		opts = &LoggerOptions{}
	}
	output := opts.Output
	if output == nil {
		output = DefaultOutput
	}
	level := opts.Level
	if level == NoLevel {
		level = DefaultLevel
	}
	mutex := opts.Mutex
	if mutex == nil {
		mutex = new(sync.Mutex)
	}
	l := &intLogger{
		json:       opts.JSONFormat,
		caller:     opts.IncludeLocation,
		name:       opts.Name,
		timeFormat: TimeFormat,
		mutex:      mutex,
		writer:     newWriter(output, opts.Color),
		level:      new(int32),
		exclude:    opts.Exclude,
	}
	l.setColorization(opts)
	if opts.DisableTime {
		l.timeFormat = ""
	} else if opts.TimeFormat != "" {
		l.timeFormat = opts.TimeFormat
	}
	atomic.StoreInt32(l.level, int32(level))
	return l
}
func (l *intLogger) log(name string, level Level, msg string, args ...interface{}) {
	if level < Level(atomic.LoadInt32(l.level)) {
		return
	}
	t := time.Now()
	l.mutex.Lock()
	defer l.mutex.Unlock()
	if l.exclude != nil && l.exclude(level, msg, args...) {
		return
	}
	if l.json {
		l.logJSON(t, name, level, msg, args...)
	} else {
		l.logPlain(t, name, level, msg, args...)
	}
	l.writer.Flush(level)
}