Documentation
¶
Index ¶
- Constants
- func Abort(message string)
- func Abortf(format string, args ...any)
- func ConRep(message string)
- func ConRepf(format string, args ...any)
- func DOOMScope(dg *DOOMGram, rwmu *sync.RWMutex, f func() error) error
- func EnableLogging(enable bool)
- func EnableTracing(enable bool) bool
- func File() string
- func FileLine() string
- func FileLineFunction() string
- func Function() string
- func IsLoggingEnabled() bool
- func IsMirroringToLog() bool
- func IsTracingEnabled() bool
- func Line() int
- func LineFunction() string
- func Log(severity severity.Severity, args ...any)
- func LogRequest(flags LogRequestFlags, options ...any) func(http.Handler) http.Handler
- func Logf(severity severity.Severity, format string, args ...any)
- func MirrorToLog(enable bool) bool
- func Trace(function_name string, args ...TraceArgument)
- func VersionString() string
- type BackEnd
- type BackEndEntry
- type BackEndFlag
- type BackEndHandlerFunc
- type DOOMGram
- func (d DOOMGram) EventCount() uint64
- func (d DOOMGram) EventTimeTotal() (bool, uint64)
- func (d DOOMGram) EventTimeTotalRaw() uint64
- func (d DOOMGram) MaxEventTime() (bool, uint64)
- func (d DOOMGram) MinEventTime() (bool, uint64)
- func (d DOOMGram) NumEventsIe100s() uint64
- func (d DOOMGram) NumEventsIn100ms() uint64
- func (d DOOMGram) NumEventsIn100ns() uint64
- func (d DOOMGram) NumEventsIn100us() uint64
- func (d DOOMGram) NumEventsIn10ms() uint64
- func (d DOOMGram) NumEventsIn10ns() uint64
- func (d DOOMGram) NumEventsIn10s() uint64
- func (d DOOMGram) NumEventsIn10us() uint64
- func (d DOOMGram) NumEventsIn1ms() uint64
- func (d DOOMGram) NumEventsIn1ns() uint64
- func (d DOOMGram) NumEventsIn1s() uint64
- func (d DOOMGram) NumEventsIn1us() uint64
- func (d DOOMGram) Overflowed() bool
- func (d *DOOMGram) PushEventDuration(duration time.Duration) bool
- func (d *DOOMGram) PushEventTimeMs(time_in_ms uint64) bool
- func (d *DOOMGram) PushEventTimeNs(time_in_ns uint64) bool
- func (d *DOOMGram) PushEventTimeS(time_in_s uint64) bool
- func (d *DOOMGram) PushEventTimeUs(time_in_us uint64) bool
- func (d DOOMGram) ToStrip() string
- type LogRequestFlags
- type TraceArgument
- type TraceArgumentFlags
Constants ¶
const ( AfterPrefix = "AFTER " BeforePrefix = "BEFORE " )
const ( VersionMajor uint16 = 0 VersionMinor uint16 = 12 VersionPatch uint16 = 0 VersionAB uint16 = 0xFFFF Version uint64 = (uint64(VersionMajor) << 48) + (uint64(VersionMinor) << 32) + (uint64(VersionPatch) << 16) + (uint64(VersionAB) << 0) )
Variables ¶
This section is empty.
Functions ¶
func Abort ¶ added in v0.3.0
func Abort(message string)
Issues the given message and then end the process.
If IsMirroringToLog is `true`, then the message will be emitted to the log before terminating.
func Abortf ¶ added in v0.3.2
Issues a formatted message and then end the process.
If IsMirroringToLog is `true`, then the message will be emitted to the log before terminating.
func ConRep ¶ added in v0.3.0
func ConRep(message string)
Issues the given message to the standard error stream.
If IsMirroringToLog is `true`, then the message will also be emitted to the log.
func ConRepf ¶ added in v0.3.2
Issues a formatted message to the standard error stream.
If IsMirroringToLog is `true`, then the message will also be emitted to the log.
func DOOMScope ¶ added in v0.11.0
Invokes a function in a timed manner and updates the DOOMGram instance, with access protected by the sync.RWMutex if provided.
Parameters:
- dg The DOOMGram instance to be modified;
- rwmu Optional sync.RWMutex with which to protect access to dg;
- fn Function to be timed;
func EnableLogging ¶ added in v0.2.0
func EnableLogging(enable bool)
Sets whether logging is enabled.
func EnableTracing ¶
Enables tracing globally (for all threads/goroutines).
func File ¶ added in v0.10.0
func File() string
Obtains the file information for the calling function.
func FileLine ¶ added in v0.7.0
func FileLine() string
Obtains the file and line information for the calling function.
func FileLineFunction ¶ added in v0.7.0
func FileLineFunction() string
Obtains the file, line, and function information for the calling function.
func Function ¶ added in v0.12.0
func Function() string
Obtains the function information for the calling function.
func IsLoggingEnabled ¶ added in v0.2.0
func IsLoggingEnabled() bool
Indicates whether logging is enabled.
func IsMirroringToLog ¶ added in v0.3.0
func IsMirroringToLog() bool
Indicates whether mirroring contingent reports (via ConRep, ConRepf, Abort, Abortf) to the log.
If IsMirroringToLog is `true`, then the message will also be emitted to the log before terminating.
func IsTracingEnabled ¶
func IsTracingEnabled() bool
Indicates whether tracing is enabled globally (for all threads/goroutines).
func LineFunction ¶ added in v0.12.0
func LineFunction() string
Obtains the line and function information for the calling function.
func LogRequest ¶ added in v0.4.0
Middleware adapter that causes a request to be logged, according to the given flags and options
Parameters:
- +flags+ (LogRequestFlags) A combination of flags that moderate the behaviour
- +options+ Optional arguments (see below)
Options:
- * (severity.Severity) The first option of this type is used for before and/or after logging; if none specified, before and/or after logging is done using severity.Informational
func MirrorToLog ¶ added in v0.3.0
Sets whether should mirror contingent reports (via ConRep, ConRepf, Abort, Abortf) to the log.
If IsMirroringToLog is `true`, then the message will also be emitted to the log before terminating.
func Trace ¶
func Trace(function_name string, args ...TraceArgument)
Provides named-argument tracing of a function/method, as in:
import d "github.com/synesissoftware/Diagnosticism.Go"
func SomeFunction(x, y int, order string) {
d.Trace(d.FileLineFunction(),
d.Trarg("x", x),
d.Trarg("y", y),
d.TrargNameTypeOnly("order", order),
)
. . . impl. of SomeFunc()
}
The first parameter `function_name` is a string, and the remaining parameters are a variable length list of TraceArgument instances, which may be created using the `Trarg()` and `TrargNameOnly()` functions
func VersionString ¶ added in v0.5.0
func VersionString() string
Types ¶
type BackEnd ¶ added in v0.6.0
type BackEnd struct {
// Flags that control the back-end behaviour/features
Flags BackEndFlag
// The back-end handler function. May not be nil
HandlerFunc BackEndHandlerFunc
// The string to be used as a separator. If the empty string, then the
// default separator - " : " - is used. If no separator is desired, the
// NoPrefixSeparator flag must be specified
PrefixSeparator string
}
Backend log handler.
func GetBackEndHandlerFunc ¶ added in v0.6.0
func GetBackEndHandlerFunc() *BackEnd
Obtains the current backend handler function.
func SetBackEnd ¶ added in v0.6.0
type BackEndEntry ¶ added in v0.6.0
type BackEndEntry struct {
// The severity of the log statement.
Severity severity.Severity
// The time at which the log statement was consumed.
Time time.Time
// The statement message.
Message string
}
Type describing an entry to be processed by the logging back-end.
type BackEndFlag ¶ added in v0.6.0
type BackEndFlag int
Flags for controlling back-end behaviour/features.
const ( NoPrefix BackEndFlag = 1 NoPrefixSeparator BackEndFlag = 2 NoTime BackEndFlag = 4 )
type BackEndHandlerFunc ¶ added in v0.6.0
type BackEndHandlerFunc func(be *BackEnd, bee *BackEndEntry)
The BackEndHandlerFunc is called when a log statement is to be emitted.
type DOOMGram ¶ added in v0.8.0
type DOOMGram struct {
// contains filtered or unexported fields
}
Decimal Order-Of-Magnitude frequency histoGRAM
# Note: This is a Go port of the equivalent `stlsoft::doomgram` class from the **STLSoft** libraries (https://github.com/synesissoftware/STLSoft-1.11).
func (DOOMGram) EventCount ¶ added in v0.8.0
Number of events counted.
func (DOOMGram) EventTimeTotal ¶ added in v0.8.0
Attempts to obtain the total event time (in nanoseconds).
func (DOOMGram) EventTimeTotalRaw ¶ added in v0.8.0
Obtains the total event time (in nanoseconds), regardless of whether overflow has occurred.
func (DOOMGram) MaxEventTime ¶ added in v0.8.0
Attempts to obtain the maximum event time.
func (DOOMGram) MinEventTime ¶ added in v0.8.0
Attempts to obtain the minimum event time.
func (DOOMGram) NumEventsIe100s ¶ added in v0.8.0
Number of events counted in the interval [100s, ∞).
func (DOOMGram) NumEventsIn100ms ¶ added in v0.8.0
Number of events counted in the interval [100ms, 1s).
func (DOOMGram) NumEventsIn100ns ¶ added in v0.8.0
Number of events counted in the interval [100ns, 1µs).
func (DOOMGram) NumEventsIn100us ¶ added in v0.8.0
Number of events counted in the interval [100µs, 1ms).
func (DOOMGram) NumEventsIn10ms ¶ added in v0.8.0
Number of events counted in the interval [10ms, 100ms).
func (DOOMGram) NumEventsIn10ns ¶ added in v0.8.0
Number of events counted in the interval [10ns, 100ns).
func (DOOMGram) NumEventsIn10s ¶ added in v0.8.0
Number of events counted in the interval [10s, 100s).
func (DOOMGram) NumEventsIn10us ¶ added in v0.8.0
Number of events counted in the interval [10µs, 100µs).
func (DOOMGram) NumEventsIn1ms ¶ added in v0.8.0
Number of events counted in the interval [1ms, 10ms).
func (DOOMGram) NumEventsIn1ns ¶ added in v0.8.0
Number of events counted in the interval [1ns, 10ns).
func (DOOMGram) NumEventsIn1s ¶ added in v0.8.0
Number of events counted in the interval [1s, 10s).
func (DOOMGram) NumEventsIn1us ¶ added in v0.8.0
Number of events counted in the interval [1µs, 10µs).
func (DOOMGram) Overflowed ¶ added in v0.8.0
Indicates whether overflow has occurred.
func (*DOOMGram) PushEventDuration ¶ added in v0.8.0
func (*DOOMGram) PushEventTimeMs ¶ added in v0.8.0
func (*DOOMGram) PushEventTimeNs ¶ added in v0.8.0
func (*DOOMGram) PushEventTimeS ¶ added in v0.8.0
func (*DOOMGram) PushEventTimeUs ¶ added in v0.8.0
type LogRequestFlags ¶ added in v0.4.0
type LogRequestFlags int
const ( // Do not log before the request LogRequest_NotBefore LogRequestFlags = 1 << iota // Do not log after the request LogRequest_NotAfter LogRequestFlags = 1 << iota // Do not include a BEFORE/AFTER prefix LogRequest_NoWhenLabel LogRequestFlags = 1 << iota // Do not include the method LogRequest_NotMethod LogRequestFlags = 1 << iota // Do not include the URL LogRequest_NotURL LogRequestFlags = 1 << iota // Include the protocol LogRequest_Protocol LogRequestFlags = 1 << iota )
type TraceArgument ¶
type TraceArgument struct {
Name string
Value any
Flags TraceArgumentFlags
}
Structure defining trace argument, generated by Trarg and TrargNameOnly.
func Trarg ¶
func Trarg(name string, value any) TraceArgument
Creates an argument descriptor that will trace the argument name, type, and value.
func TrargNameOnly ¶
func TrargNameOnly(name string, value any) TraceArgument
Creates an argument descriptor that will trace the argument name, but not type and value.
func TrargNameTypeOnly ¶ added in v0.9.0
func TrargNameTypeOnly(name string, value any) TraceArgument
Creates an argument descriptor that will trace the argument name and type, but not value.
func TrargTrunc ¶ added in v0.9.0
func TrargTrunc(name string, value any) TraceArgument
func (TraceArgument) String ¶ added in v0.2.0
func (arg TraceArgument) String() string
type TraceArgumentFlags ¶ added in v0.9.0
type TraceArgumentFlags int64
Flags type for [TraceArgument.Flags].
const ( None TraceArgumentFlags = 0 // No flags specified NameOnly TraceArgumentFlags = 0x0000_0000_0000_0001 // Does not trace the value of a function parameter. NameTypeOnly TraceArgumentFlags = 0x0000_0000_0000_0002 // Does not trace the type or the value of a function parameter. TruncateValue TraceArgumentFlags = 0x0000_0000_0000_0004 // Causes the value to be truncated to 20 runes. )