logx

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 14 Imported by: 4

Documentation

Overview

----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Lord of Scripts * goApp * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Convenience Logging functions present when "logx" tag is used. *-----------------------------------------------------------------

Index

Constants

View Source
const (
	UC_FOOTSTEPS   rune = rune(0x1f463) // 👣
	UC_EXCLAMATION rune = rune(0x2757)  // ❗
	UC_CROSSMARK   rune = rune(0x274c)  // ❌
	UC_CROSS       rune = rune(0x2716)  // ✖
	UC_CHECK       rune = rune(0x1f5f8) // 🗸
	UC_ARROWS3     rune = rune(0x21f6)  // ⇶
	UC_OBSERVER    rune = rune(0x23ff)  // ⏿
	UC_EYES        rune = rune(0x1f440) // 👀
	UC_EYE         rune = rune(0x1f441) // 👁
)

---------------------------------------------------------------- * P u b l i c G l o b a l s *-----------------------------------------------------------------

Variables

This section is empty.

Functions

func GetNestingLevel

func GetNestingLevel(frCnt ...int) (int, string)

*

  • Gets the current nesting level with main.main() as reference and
  • a string with the location (package/struct/function).

Types

type ICallTree

type ICallTree interface {
}

type LogFilter

type LogFilter struct {
	LogLevel     string `json:"log_level"`
	Specifically string `json:"specifically,omitempty"`
}

type LogGate

type LogGate struct {
	AppName      string               `json:"appname"`
	CurrentLevel string               `json:"level"` // allowed log level: NONE,FATAL,ERROR,WARN,INFO,DEBUG
	Filters      map[string]LogFilter `json:"filters"`
	// contains filtered or unexported fields
}
var (
	SingLogGate *LogGate // Singleton for App CLI parsing and Filtering
)

func GetLogGateInstance

func GetLogGateInstance(names ...string) *LogGate

*

  • Manages the Logging configuration for the application lifecycle
  • Allowing to easily set it up via a CLI parameter to disable
  • logging, or enable to a terminal or a named file. *
  • @returns LogGate{} singleton

func (*LogGate) Close

func (l *LogGate) Close()

*

  • This call is only necessary if the application is logging to a file.
  • In that case it is better to put a call to this on a defer statement
  • on the main function.

func (*LogGate) DisableLogging

func (l *LogGate) DisableLogging()

DisableLogging disables logging in the application

func (*LogGate) EnableLogging

func (l *LogGate) EnableLogging()

EnableLogging enables logging for tests

func (*LogGate) EnableLoggingToDir

func (l *LogGate) EnableLoggingToDir(dirname string) error

*

  • Enable logging to file.
  • @returns (*os.File) so that the caller can defer Close()

func (*LogGate) EnableLoggingToFile

func (l *LogGate) EnableLoggingToFile(filename string) error

func (*LogGate) Help

func (l *LogGate) Help() string

func (*LogGate) IsFiltered

func (l *LogGate) IsFiltered(packageName string) bool

*

  • Checks if the packageName (GO package name format) is
  • black-listed. Black-listed packages do not produce log
  • output under LOGX.

func (*LogGate) IsFilteredObject

func (l *LogGate) IsFilteredObject(packageName, objectName string) bool

*

  • Checks if the packageName (GO package name format) is
  • black-listed. Black-listed packages do not produce log
  • output under LOGX.

func (*LogGate) LoadFilters

func (l *LogGate) LoadFilters() error

*

  • Attempts to load APPNAME.logfilters which contains a list of application/module
  • packages white-listed for log output. It may contain a fine-grained configuration
  • of which objects (structs) of that package are allowed. If empty all are allowed,
  • else whatever struct name that is not listed becomes black-listed for logging.

func (*LogGate) SaveFilters

func (l *LogGate) SaveFilters()

*

  • Saves a sample Log Filter configuration file in the user's configuration
  • directory. The filename is APPNAME.logfilter.

func (*LogGate) SetAppName

func (l *LogGate) SetAppName(name string) *LogGate

func (*LogGate) Setup

func (l *LogGate) Setup(mode string)

func (*LogGate) WithCallTree

func (l *LogGate) WithCallTree(filename string) *LogGate

func (*LogGate) WithConfigSubdirectory

func (l *LogGate) WithConfigSubdirectory(subdir string) *LogGate

func (*LogGate) WriteCallTree

func (l *LogGate) WriteCallTree(data string)

Writes to the call tree (separate file or default output). The data string is expected WITHOUT line feed ("\n") as it will be appended here.

Jump to

Keyboard shortcuts

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