github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/log/log-helpers.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package log
     4  
     5  import (
     6  	"github.com/GeniusesGroup/libgo/protocol"
     7  )
     8  
     9  // TODO::: Can't force compiler to inline below functions, Delete file to force developers use this way:
    10  // protocol.App.Log(log.ConfEvent(domainEnglish, "???"))
    11  
    12  // Trace make new event with given level and add stack trace and log it to protocol.App
    13  func Trace(level protocol.LogType, domain, message string) (err protocol.Error) {
    14  	// var e Event
    15  	// e.Init(level, domain, message, true)
    16  	return protocol.App.Log(TraceEvent(level, domain, message))
    17  }
    18  
    19  // Info make new event with "Information" level and log it to protocol.App
    20  func Info(domain, message string) (err protocol.Error) {
    21  	var e Event
    22  	e.Init(protocol.LogEvent_Information, domain, message, false)
    23  	return protocol.App.Log(&e)
    24  }
    25  
    26  // Notice make new event with "Notice" level and log it to protocol.App
    27  func Notice(domain, message string) (err protocol.Error) {
    28  	var e Event
    29  	e.Init(protocol.LogEvent_Notice, domain, message, false)
    30  	return protocol.App.Log(&e)
    31  }
    32  
    33  // Debug make new event with "Debug" level and log it to protocol.App
    34  func Debug(domain, message string) (err protocol.Error) {
    35  	var e Event
    36  	e.Init(protocol.LogEvent_Debug, domain, message, false)
    37  	return protocol.App.Log(&e)
    38  }
    39  
    40  // DeepDebug make new event with "DeepDebug" level and log it to protocol.App
    41  func DeepDebug(domain, message string) (err protocol.Error) {
    42  	var e Event
    43  	e.Init(protocol.LogEvent_DeepDebug, domain, message, false)
    44  	return protocol.App.Log(&e)
    45  }
    46  
    47  // Warn make new event with "Warning" level and log it to protocol.App
    48  func Warn(domain, message string) (err protocol.Error) {
    49  	var e Event
    50  	e.Init(protocol.LogEvent_Warning, domain, message, false)
    51  	return protocol.App.Log(&e)
    52  }
    53  
    54  // Panic make new event with "Panic" level and log it to protocol.App
    55  func Panic(domain, message string) (err protocol.Error) {
    56  	var e Event
    57  	e.Init(protocol.LogEvent_Panic, domain, message, true)
    58  	return protocol.App.Log(&e)
    59  }
    60  
    61  // Fatal make new event with "Fatal" level and log it to protocol.App
    62  func Fatal(domain, message string) (err protocol.Error) {
    63  	var e Event
    64  	e.Init(protocol.LogEvent_Fatal, domain, message, true)
    65  	return protocol.App.Log(&e)
    66  }
    67  
    68  // Conf make new event with "Confidential" level and log it to protocol.App
    69  func Conf(domain, message string) (err protocol.Error) {
    70  	var e Event
    71  	e.Init(protocol.LogEvent_Confidential, domain, message, false)
    72  	return protocol.App.Log(&e)
    73  }