simplelog

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 4 Imported by: 5

Documentation

Index

Constants

View Source
const (
	LOG_ERROR   = 1
	LOG_NORMAL  = 5
	LOG_VERBOSE = 10

	DB_ARRAY_FIELD_SEPARATOR = "|"

	ERROR_PREFIX   = "!!!"
	WARNING_PREFIX = "---"

	COUNTRY_PHONE_SEPARATOR = "."
	COUNTRY_PHONE_PREFIX    = "+"
)

Variables

View Source
var (
	DEBUG_LEVEL int = 10 // 0 means no DEBUGGING info, higher number higher info
	// DEBUG_LEVEL     = 5
	DEBUG_PREFIX        string = "#"
	DEBUG_SUFFIX        string = ""
	DEBUG_VALUE         string = ": "
	DEBUG_SEPARATOR     string = ", "
	DEBUG_TRIM_FUNCTION bool   = true // for GetCallerFunction, do we remove/trim the leading filename info etc?
	// JoinAlias        func([]string, string) string = strings.Join
	// Aliases
	LogInfo func(string, int, ...string) = LogInfoStr
)

Functions

func ConverPhoneToE164

func ConverPhoneToE164(phone string) string

This is the format of E.164 phone: +[country_code][complete phone] Our format now is +[country_code].[complete phone] complete phone must be all number, cannot contain any symbols

func ConvertPhoneToUsername

func ConvertPhoneToUsername(phone string) string

NOTE: Phone has to be informat +[country_code].[phone number without leading 0] This convert phone +62.812039124 to username = "62.81231241"

func ConvertUsernameToPhones

func ConvertUsernameToPhones(uname string) (string, string)

NOT USED NOTE: maybe just removing the + sign, below is wrong! Convert username "62.8123512" to phone "+628123027521"

func GetCallerFunctionName

func GetCallerFunctionName(iStack int) string

To get previous caller need to pass 1 for stack, but since this is used inside the function that need to know the caller, we need to have 2. To get default, value use 0 as argument

func InitUtils

func InitUtils()

No need to use this anymore because it was used only to seed math random generator Now since go 1.20 there is no need to do this anymore. If we need to initialize util in the future then use this again

func JoinDebug

func JoinDebug(elems []string) string

Default strings join function with DEBUG_SEPARATOR

func LoadDefaults

func LoadDefaults()

NOTE: NOT USED

func LogAny

func LogAny(msgs ...any)

func LogErr

func LogErr(err error, msgs ...any)

Default log error, which we get the caller function-stack default(1) NOTE: this disregard DEBUG_LEVEL and only print if there is error (!= nil)

func LogError

func LogError(fn string, err error, msgs ...string)

Make console log (more readble code). Remember this doesn't use DEBUG_LEVEL, it always print as long there is error NOTE: not printing anything if there is no error

func LogErrorAny

func LogErrorAny(fn string, err error, msgs ...any)

Make console log (more readble code). Remember this doesn't use DEBUG_LEVEL, it always print as long there is error NOTE: not printing anything if there is no error

func LogErrorStr

func LogErrorStr(fn string, err error, msg string)

Make console log (more readble code). Remember this doesn't use DEBUG_LEVEL, it always print as long there is error NOTE: not printing anything if there is no error

func LogErrorStrReturn

func LogErrorStrReturn(fn string, err error, msg string) error

NOT USED

func LogFormat

func LogFormat(format string, v ...any)

func LogInfoAny

func LogInfoAny(fn string, level int, msgs ...any)

Only log, but not returning anything, message = any

func LogInfoAnyReturn

func LogInfoAnyReturn(fn string, level int, err error, msgs ...any) error

Log MULTIPLE messages = any, and return error

func LogInfoStr

func LogInfoStr(fn string, level int, msgs ...string)

Only log, but not returning anything, message = string

func LogInfoStrReturn

func LogInfoStrReturn(fn string, level int, err error, msgs ...string) error

Log MULTIPLE message = string and return error object NOTE: NOT USED

func LogThis

func LogThis(msgs ...string)

Simplest log model, just like the default go lang log package or println Basically called with function-stack default (-1) the previous caller of this function and using the current DEBUG_LEVEL

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL