Skip to content
Snippets Groups Projects
Select Git revision
  • a399051eae419d725c0a2e91b21d436bfd7f6202
  • main default protected
  • trading_hours
  • refactor_trading_hours
  • audit_cleaning_cater_for_non_struct_fields
  • remove-info-logs
  • sl-refactor
  • 18-use-scan-for-param-values
  • 17-order-search-results
  • 4-simplify-framework-2
  • 1-http-error
  • v1.297.0
  • v1.296.0
  • v1.295.0
  • v1.294.0
  • v1.293.0
  • v1.292.0
  • v1.291.0
  • v1.290.0
  • v1.289.0
  • v1.288.0
  • v1.287.0
  • v1.286.0
  • v1.285.0
  • v1.284.0
  • v1.283.0
  • v1.282.0
  • v1.281.0
  • v1.280.0
  • v1.279.0
  • v1.278.0
31 results

handler.go

Blame
  • logs_test.go 1.38 KiB
    package logger_test
    
    import (
    	"os"
    	"testing"
    
    	"github.com/fatih/color"
    	"gitlab.com/uafrica/go-utils/errors"
    	"gitlab.com/uafrica/go-utils/logger"
    )
    
    func TestLogs(t *testing.T) {
    	//requestID := t.Name()
    	//event := events.APIGatewayProxyRequest{}
    	os.Setenv("DEBUGGING", "true")
    	//logger.InitLogs(&requestID, &event)
    
    	// formatter := log.TextFormatter{}
    	// log.SetFormatter(&formatter)
    
    	logger.LogMessageWithFields(map[string]interface{}{"a": 1, "b": 2}, "MyLogMessage1")
    	logger.LogMessage("MyLogMessage2=%d,%d,%d", 1, 2, 3)
    	logger.LogError(map[string]interface{}{"a": 4, "b": 5}, errors.Errorf("simple mistake"))
    	logger.LogErrorMessage("Error Message", errors.Errorf("another simple mistake"))
    	logger.LogWarningMessage("Warning about a=%s,%s,%s", "a", "b", "c")
    	logger.LogWarning(map[string]interface{}{"a": 4, "b": 5}, errors.Errorf("Cant believe it failed"))
    	logger.SQLDebugInfo("SELECT * from user")
    	//logger.LogRequestInfo(event)
    	//logs.LogSQSEvent(sqsEvent)
    
    	ctx := logger.GetContextLogger()
    	ctx.Debugf("Debugging %d!", 456)
    	ctx.Infof("Info %d", 789)
    
    	//logs.Errorf("Debugging %d!", 456)
    	//logs.Error("Info")
    }
    
    func TestColor(t *testing.T) {
    	blue := color.New(color.FgBlue).FprintfFunc()
    	blue(os.Stdout, "important notice: %s", "ssss")
    
    	// Mix up with multiple attributes
    	success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
    	success(os.Stdout, " don't forget this...")
    }