{"id":22973194,"url":"https://github.com/gabrielhcataldo/go-logger","last_synced_at":"2025-04-02T07:14:48.010Z","repository":{"id":219906554,"uuid":"728671506","full_name":"GabrielHCataldo/go-logger","owner":"GabrielHCataldo","description":"📑 Lightweight, fully configurable and open source log library written in Go. Supports multiple inputs, and easily customized outputs with value masks for all types.","archived":false,"fork":false,"pushed_at":"2024-05-15T20:20:56.000Z","size":243,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T21:42:44.778Z","etag":null,"topics":["console-log","formatter","go-logger","log","log-processor","logger","loggers","logging","monolog","structured-logging"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/GabrielHCataldo/go-logger/logger","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GabrielHCataldo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-07T12:50:20.000Z","updated_at":"2024-05-15T20:20:41.000Z","dependencies_parsed_at":"2024-01-30T09:46:45.104Z","dependency_job_id":"ebb3b003-2780-4196-a19c-aab70230b30f","html_url":"https://github.com/GabrielHCataldo/go-logger","commit_stats":null,"previous_names":["gabrielhcataldo/go-logger"],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielHCataldo%2Fgo-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielHCataldo%2Fgo-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielHCataldo%2Fgo-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielHCataldo%2Fgo-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GabrielHCataldo","download_url":"https://codeload.github.com/GabrielHCataldo/go-logger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246769968,"owners_count":20830771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["console-log","formatter","go-logger","log","log-processor","logger","loggers","logging","monolog","structured-logging"],"created_at":"2024-12-14T23:40:14.492Z","updated_at":"2025-04-02T07:14:47.990Z","avatar_url":"https://github.com/GabrielHCataldo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"go-logger\n=================\n\u003cimg align=\"right\" src=\"gopher-logger.png\" alt=\"\"\u003e\n\n[![Project status](https://img.shields.io/badge/version-v1.3.4-vividgreen.svg)](https://github.com/GabrielHCataldo/go-logger/releases/tag/v1.3.4)\n[![Go Report Card](https://goreportcard.com/badge/github.com/GabrielHCataldo/go-logger)](https://goreportcard.com/report/github.com/GabrielHCataldo/go-logger)\n[![Coverage Status](https://coveralls.io/repos/GabrielHCataldo/go-logger/badge.svg?branch=main\u0026service=github)](https://coveralls.io/github/GabrielHCataldo/go-logger?branch=main)\n[![Open Source Helpers](https://www.codetriage.com/gabrielhcataldo/go-logger/badges/users.svg)](https://www.codetriage.com/gabrielhcataldo/go-logger)\n[![GoDoc](https://godoc.org/github/GabrielHCataldo/go-logger?status.svg)](https://pkg.go.dev/github.com/GabrielHCataldo/go-logger/logger)\n![License](https://img.shields.io/dub/l/vibe-d.svg)\n\nThe go-logger project came to facilitate and increase your project's log customization capacity, being the most complete\nfrom the market. Below are functions to use:\n\n- Log Level (Info, Debug, Warn, Error)\n- Different message modes (Default or Json)\n- Information mask for all types\n- Information hide for all types\n- Mask customization (Mask start or Mask end)\n- Print log asynchronously\n- Customization globally or locally\n- Date and time format customization\n- Have the option to print only the message has content\n- Simplicity in calls\n\nInstallation\n------------\n\nUse go get.\n\n\tgo get github.com/GabrielHCataldo/go-logger\n\nThen import the go-logger package into your own code.\n\n```go\nimport \"github.com/GabrielHCataldo/go-logger/logger\"\n```\n\nUsability and documentation\n------------\n**IMPORTANT**: Always check the documentation in the structures and functions fields.\nFor more details on the examples, visit [All examples link](https://github/GabrielHCataldo/go-logger/blob/main/_example/main.go)\n\nUsing go-logger's features is very easy, let's start with a basic example:\n\n```go\nimport \"github.com/GabrielHCataldo/go-logger/logger\"\n\nfunc main() {\n    basicMsg := getBasicMsg()\n    logger.Info(basicMsg...)\n    logger.Debug(basicMsg...)\n    logger.Warn(basicMsg...)\n    logger.Error(basicMsg...)\n}\n\nfunc getBasicMsg() []any {\n    return []any{\"basic example with empty any values\", nil, \"\", 0, map[string]any{}, []any{}}\n}\n```\n\nOutputs:\n\n    [INFO 2023/12/10 17:23:09] main.go:5: basic example with empty any values  0 {} null\n    [DEBUG 2023/12/10 17:23:09] main.go:6: basic example with empty any values  0 {} null\n    [WARN 2023/12/10 17:23:09] main.go:7: basic example with empty any values  0 {} null\n    [ERROR 2023/12/10 17:23:09] main.go:8: basic example with empty any values  0 {} null\n\nWe can modify this default structure to a JSON log structure, just edit its global options like\nbelow:\n\n```go\nimport \"github.com/GabrielHCataldo/go-logger/logger\"\n\nfunc main() {\n    // set on global options\n    logger.SetOptions(\u0026logger.Options{\n        // Out represents an io.Writer that is used for the logging output.\n        Out: os.Stdout,\n        // Level field represents the logging level. It is of type `level`.\n        Level: logger.WarnLevel,\n        // Print mode (default: ModeDefault)\n        Mode: logger.ModeJson,\n        // Argument date format (default: DateFormatFull24h)\n        DateFormat: logger.DateFormatFull24h,\n        // Custom prefix text\n        CustomPrefixText: \"\",\n        // Custom after prefix text (only if Mode is ModeDefault)\n        CustomAfterPrefixText: \"\",\n        // Enable asynchronous printing mode (default: false)\n        EnableAsynchronousMode: false,\n        // Enable argument date to be UTC (default: false)\n        UTC: false,\n        // Enable to not print empty message (default: false)\n        DontPrintEmptyMessage: false,\n        // Enable to remove spaces between parameters (default: false)\n        RemoveSpace: false,\n        // If true will hide all datetime and prefix arguments (default: false)\n        HideAllArgs: false,\n        // If true it will hide the datetime arguments (default: false)\n        HideArgDatetime: false,\n        // If true, it will hide the caller arguments (default: false)\n        HideArgCaller: false,\n        // If true, it will disable all argument and prefix colors (default: false)\n        DisablePrefixColors: false,\n        // If true, json mode msg field becomes slice (default: false, only if Mode is ModeJson)\n        //\n        // IMPORTANT: If true, the format parameter will not work\n        EnableJsonMsgFieldForSlice: false,\n    })\n    basicMsg := getBasicMsg()\n    logger.Info(basicMsg...)\n    logger.Debug(basicMsg...)\n    logger.Warn(basicMsg...)\n    logger.Error(basicMsg...)\n}\n\nfunc getBasicMsg() []any {\n    return []any{\"basic example with empty any values\", nil, \"\", 0, map[string]any{}, []any{}}\n}\n```\n\nOutputs:\n\n    {\"level\":\"warn\",\"datetime\":\"2023/12/10 17:18:09\",\"file\":\"main.go\",\"func\":\"main.main\",\"line\":\"11\",\"msg\":\"basic example with empty any values  0 {} null\"}\n    {\"level\":\"error\",\"datetime\":\"2023/12/10 17:18:09\",\"file\":\"main.go\",\"func\":\"main.main\",\"line\":\"12\",\"msg\":\"basic example with empty any values  0 {} null\"}\n\nYou can also pass custom options as a parameter so as not to impact the defined global settings,\njust use the functions with the **Opts** pattern, see:\n\n```go\nimport \"github.com/GabrielHCataldo/go-logger/logger\"\n\nfunc main() {\n    opts := logger.Options{\n        // Print mode (default: ModeDefault)\n        Mode: logger.ModeJson,\n        // Argument date format (default: DateFormatFull24h)\n        DateFormat: logger.DateFormatFull24h,\n        // Custom prefix text\n        CustomPrefixText: \"\",\n        // Custom after prefix text (only if Mode is ModeDefault)\n        CustomAfterPrefixText: \"\",\n        // Enable asynchronous printing mode (default: false)\n        EnableAsynchronousMode: false,\n        // Enable argument date to be UTC (default: false)\n        UTC: false,\n        // Enable to not print empty message (default: false)\n        DontPrintEmptyMessage: false,\n        // Enable to remove spaces between parameters (default: false)\n        RemoveSpace: false,\n        // If true will hide all datetime and prefix arguments (default: false)\n        HideAllArgs: false,\n        // If true it will hide the datetime arguments (default: false)\n        HideArgDatetime: false,\n        // If true, it will hide the caller arguments (default: false)\n        HideArgCaller: false,\n        // If true, it will disable all argument and prefix colors (default: false)\n        DisablePrefixColors: false,\n        // If true, json mode msg field becomes slice (default: false, only if Mode is ModeJson)\n        //\n        // IMPORTANT: If true, the format parameter will not work\n        EnableJsonMsgFieldForSlice: false,\n    }\n    basicMsg := getBasicMsg()\n    logger.InfoOpts(opts, basicMsg...)\n    // field msg json to slice\n    opts.EnableJsonMsgFieldForSlice = true\n    logger.DebugOpts(opts, basicMsg...)\n    logger.Warn(basicMsg...)\n    logger.Error(basicMsg...)\n}\n\nfunc getBasicMsg() []any {\n    return []any{\"basic example with empty any values\", nil, \"\", 0, map[string]any{}, []any{}}\n}\n```\n\nOutputs:\n\n    {\"level\":\"info\",\"datetime\":\"2023/12/11 08:17:09\",\"file\":\"main.go\",\"func\":\"main.main\",\"line\":\"50\",\"msg\":\"basic example with any values text string 1 12.213 true 2023-12-11T08:17:14-03:00 {\\\"int\\\":1,\\\"float\\\":12.213,\\\"string\\\":\\\"text string\\\",\\\"bool\\\":true,\\\"time\\\":\\\"2023-12-11T08:17:14-03:00\\\",\\\"nilValue\\\":null} [\\\"text string\\\",1,12.213,true,null,\\\"2023-12-11T08:17:14-03:00\\\"]\"}\n    {\"level\":\"debug\",\"datetime\":\"2023/12/11 08:17:09\",\"file\":\"main.go\",\"func\":\"main.main\",\"line\":\"53\",\"msg\":[\"basic example with any values\",\"text string\",1,12.213,true,\"2023-12-11T08:17:14-03:00\",{\"bool\":true,\"float\":12.213,\"int\":1,\"nilValue\":null,\"string\":\"text string\",\"time\":\"2023-12-11T08:17:14-03:00\"},[\"text string\",1,12.213,true,null,\"2023-12-11T08:17:14-03:00\"]]}\n    [WARN 2023/12/11 08:17:09] main.go:54: basic example with any values text string 1 12.213 true 2023-12-11T08:17:14-03:00 {\"float\":12.213,\"string\":\"text string\",\"bool\":true,\"time\":\"2023-12-11T08:17:14-03:00\",\"nilValue\":null,\"int\":1} [\"text string\",1,12.213,true,null,\"2023-12-11T08:17:14-03:00\"]\n    [ERROR 2023/12/11 08:17:09] main.go:55: basic example with any values text string 1 12.213 true 2023-12-11T08:17:14-03:00 {\"time\":\"2023-12-11T08:17:14-03:00\",\"nilValue\":null,\"int\":1,\"float\":12.213,\"string\":\"text string\",\"bool\":true} [\"text string\",1,12.213,true,null,\"2023-12-11T08:17:14-03:00\"]\n\nIn go-logger we have the same **format** pattern as a parameter in some native functions,\nThis value formats the parameters passed in **v**, works both in standard mode and in default mode.\nJSON, just call the functions with the **f** pattern, see some examples below:\n\n```go\nimport \"github.com/GabrielHCataldo/go-logger/logger\"\n\nfunc main() {\n    customOpts := logger.Options{\n        // Print mode (default: ModeDefault)\n        Mode: logger.ModeJson,\n        // Argument date format (default: DateFormatFull24h)\n        DateFormat: logger.DateFormatAbbrTextDatetime12h,\n        // Custom prefix text\n        CustomPrefixText: \"\",\n        // Custom after prefix text (only if Mode is ModeDefault)\n        CustomAfterPrefixText: \"\",\n        // Enable asynchronous printing mode (default: false)\n        EnableAsynchronousMode: false,\n        // Enable argument date to be UTC (default: false)\n        UTC: false,\n        // Enable to not print empty message (default: false)\n        DontPrintEmptyMessage: false,\n        // Enable to remove spaces between parameters (default: false)\n        RemoveSpace: false,\n        // If true will hide all datetime and prefix arguments (default: false)\n        HideAllArgs: false,\n        // If true it will hide the datetime arguments (default: false)\n        HideArgDatetime: false,\n        // If true, it will hide the caller arguments (default: false)\n        HideArgCaller: false,\n        // If true, it will disable all argument and prefix colors (default: false)\n        DisablePrefixColors: false,\n        // If true, json mode msg field becomes slice (default: false, only if Mode is ModeJson)\n        //\n        // IMPORTANT: If true, the format parameter will not work\n        EnableJsonMsgFieldForSlice: false,\n    }\n    format := \"%v, %v, %v, %v, %v, %v, %v, last is %v\"\n    msg := getBasicMsg()\n    logger.Infof(format, msg...)\n    logger.DebugOptsf(format, customOpts, msg...)\n    logger.WarnfMS(format, msg...)\n    logger.ErrorOptsfMS(format, customOpts, msg...)\n}\n\nfunc getBasicMsg() []any {\n    s := []any{\n        \"text string\",\n        1,\n        12.213,\n        true,\n        nil,\n        time.Now(),\n    }\n    m := map[string]any{\n        \"int\":      1,\n        \"float\":    12.213,\n        \"string\":   \"text string\",\n        \"bool\":     true,\n        \"nilValue\": nil,\n        \"time\":     time.Now(),\n    }\n    return []any{\"basic example with any values\", \"text string\", 1, 12.213, true, time.Now(), m, s}\n}\n```\n\nOutputs: \n\n    [INFO 2023/12/11 07:53:09] main.go:9: basic example with any values, text string, 1, 12.213, true, 2023-12-11T07:53:41-03:00, {\"nilValue\":null,\"int\":1,\"float\":12.213,\"string\":\"text string\",\"bool\":true,\"time\":\"2023-12-11T07:53:41-03:00\"}, last is [\"text string\",1,12.213,true,null,\"2023-12-11T07:53:41-03:00\"]\n    {\"level\":\"debug\",\"datetime\":\"Dec 11 Mon 7:53:41 AM\",\"file\":\"types.go\",\"func\":\"main.main\",\"line\":\"10\",\"msg\":\"*****************************, ***********, *, ******, ****, *************************, {\\\"time\\\":\\\"*************************\\\",\\\"nilValue\\\":null,\\\"int\\\":\\\"*\\\",\\\"float\\\":\\\"******\\\",\\\"string\\\":\\\"***********\\\",\\\"bool\\\":\\\"****\\\"}, last is [\\\"***********\\\",\\\"*\\\",\\\"******\\\",\\\"****\\\",null,\\\"*************************\\\"]\"}\n    [WARN 2023/12/11 07:53:09] main.go:11: **************with any values, *****string, *, ***213, **ue, ************7:53:41-03:00, {\"nilValue\":null,\"int\":\"*\",\"float\":\"***213\",\"string\":\"*****string\",\"bool\":\"**ue\",\"time\":\"************7:53:41-03:00\"}, last is [\"*****string\",\"*\",\"***213\",\"**ue\",null,\"************7:53:41-03:00\"]\n    {\"level\":\"error\",\"datetime\":\"Dec 11 Mon 7:53:41 AM\",\"file\":\"types.go\",\"func\":\"main.main\",\"line\":\"12\",\"msg\":\"**************with any values, *****string, *, ***213, **ue, ************7:53:41-03:00, {\\\"float\\\":\\\"***213\\\",\\\"string\\\":\\\"*****string\\\",\\\"bool\\\":\\\"**ue\\\",\\\"time\\\":\\\"************7:53:41-03:00\\\",\\\"nilValue\\\":null,\\\"int\\\":\\\"*\\\"}, last is [\\\"*****string\\\",\\\"*\\\",\\\"***213\\\",\\\"**ue\\\",null,\\\"************7:53:41-03:00\\\"]\"}\n\nFor a clearer debug, we have in our argument the caller's name and line, to be more precise in some cases\nsub calls, for example, you can call functions with the **SkipCaller** pattern and pass the number you want\nas a parameter to skip the caller, see an example below:\n\n```go\nimport \"github.com/GabrielHCataldo/go-logger/logger\"\n\nfunc main() {\n    subFunc()\n}\n\nfunc subFunc() {\n    customOpts := logger.Options{\n        // Print mode (default: ModeDefault)\n        Mode: logger.ModeJson,\n        // Argument date format (default: DateFormatFull24h)\n        DateFormat: logger.DateFormatAbbrTextDatetime12h,\n        // Custom prefix text\n        CustomPrefixText: \"\",\n        // Custom after prefix text (only if Mode is ModeDefault)\n        CustomAfterPrefixText: \"\",\n        // Enable asynchronous printing mode (default: false)\n        EnableAsynchronousMode: false,\n        // Enable argument date to be UTC (default: false)\n        UTC: false,\n        // Enable to not print empty message (default: false)\n        DontPrintEmptyMessage: false,\n        // Enable to remove spaces between parameters (default: false)\n        RemoveSpace: false,\n        // If true will hide all datetime and prefix arguments (default: false)\n        HideAllArgs: false,\n        // If true it will hide the datetime arguments (default: false)\n        HideArgDatetime: false,\n        // If true, it will hide the caller arguments (default: false)\n        HideArgCaller: false,\n        // If true, it will disable all argument and prefix colors (default: false)\n        DisablePrefixColors: false,\n        // If true, json mode msg field becomes slice (default: false, only if Mode is ModeJson)\n        //\n        // IMPORTANT: If true, the format parameter will not work\n        EnableJsonMsgFieldForSlice: false,\n    }\n    format := \"%v, %v, %v, %v, %v, %v, %v, last is %v\"\n    msg := getBasicMsg()\n    logger.InfoSkipCaller(1, msg...)\n    logger.DebugSkipCallerOpts(1, customOpts, msg...)\n    logger.WarnSkipCallerOptsf(format, 2, customOpts, msg...)\n    logger.ErrorSkipCaller(2, msg...)\n}\n\nfunc getBasicMsg() []any {\n    s := []any{\n        \"text string\",\n        1,\n        12.213,\n        true,\n        nil,\n        time.Now(),\n    }\n    m := map[string]any{\n        \"int\":      1,\n        \"float\":    12.213,\n        \"string\":   \"text string\",\n        \"bool\":     true,\n        \"nilValue\": nil,\n        \"time\":     time.Now(),\n    }\n    return []any{\"basic example with any values\", \"text string\", 1, 12.213, true, time.Now(), m, s}\n}\n```\n\nOutputs:\n    \n    [INFO 2023/12/11 08:37:09] main.go:23: basic example with any values text string 1 12.213 true 2023-12-11T08:37:01-03:00 {\"nilValue\":null,\"int\":1,\"float\":12.213,\"string\":\"text string\",\"bool\":true,\"time\":\"2023-12-11T08:37:01-03:00\"} [\"text string\",1,12.213,true,null,\"2023-12-11T08:37:01-03:00\"]\n    {\"level\":\"debug\",\"datetime\":\"2023/12/11 8:37:01AM\",\"file\":\"main.go\",\"func\":\"main.subFunc\",\"line\":\"24\",\"msg\":\"basic example with any values text string 1 12.213 true 2023-12-11T08:37:01-03:00 {\\\"time\\\":\\\"2023-12-11T08:37:01-03:00\\\",\\\"nilValue\\\":null,\\\"int\\\":1,\\\"float\\\":12.213,\\\"string\\\":\\\"text string\\\",\\\"bool\\\":true} [\\\"text string\\\",1,12.213,true,null,\\\"2023-12-11T08:37:01-03:00\\\"]\"}\n    {\"level\":\"warn\",\"datetime\":\"2023/12/11 8:37:01AM\",\"file\":\"main.go\",\"func\":\"main.main\",\"line\":\"4\",\"msg\":\"basic example with any values, text string, 1, 12.213, true, 2023-12-11T08:37:01-03:00, {\\\"nilValue\\\":null,\\\"int\\\":1,\\\"float\\\":12.213,\\\"string\\\":\\\"text string\\\",\\\"bool\\\":true,\\\"time\\\":\\\"2023-12-11T08:37:01-03:00\\\"}, last is [\\\"text string\\\",1,12.213,true,null,\\\"2023-12-11T08:37:01-03:00\\\"]\"}\n    [ERROR 2023/12/11 08:37:09] main.go:4: basic example with any values text string 1 12.213 true 2023-12-11T08:37:01-03:00 {\"bool\":true,\"time\":\"2023-12-11T08:37:01-03:00\",\"nilValue\":null,\"int\":1,\"float\":12.213,\"string\":\"text string\"} [\"text string\",1,12.213,true,null,\"2023-12-11T08:37:01-03:00\"]\n\nWe have a complete solution to hide/mask values that works for all types, example\nBelow we will use a structure, where we will add the **logger** tag with the values **hide** | **mask_start** | **mask_end**\nindicating how we want the value to be hidden. See the example below:\n\n```go\nimport \"github.com/GabrielHCataldo/go-logger/logger\"\n\ntype test struct {\n    Name          string    `json:\"name,omitempty\"`\n    BirthDate     time.Time `json:\"birthDate,omitempty\"`\n    Document      string    `json:\"document,omitempty\" logger:\"mask_start\"`\n    Emails        []string  `json:\"emails,omitempty\"`\n    Balances      []float32 `json:\"balances,omitempty\" logger:\"mask_end\"`\n    TotalBalances []float64 `json:\"totalBalances,omitempty\"`\n    Booleans      []bool    `json:\"booleans,omitempty\"`\n    Bank          bankTest  `json:\"bank,omitempty\"`\n}\n\ntype bankTest struct {\n    AccountDigits string  `json:\"accountDigits,omitempty\"`\n    Account       string  `json:\"account,omitempty\"`\n    Balance       float32 `json:\"balance,omitempty\" logger:\"hide\"`\n    TotalBalance  float64 `json:\"totalBalance,omitempty\"`\n}\n\nfunc main() {\n    testStruct := getTestStruct()\n    msg := []any{\"test mask/hide struct:\", testStruct}\n    logger.Info(msg...)\n    logger.Debug(msg...)\n    logger.Warn(msg...)\n    logger.Error(msg...)\n}\n\nfunc getTestStruct() test {\n    bank := bankTest{\n        AccountDigits: \"123\",\n        Account:       \"123981023\",\n        Balance:       30.89,\n        TotalBalance:  200.17,\n    }\n    return test{\n        Name:      \"Foo Bar\",\n        BirthDate: time.Date(1999, 1, 21, 0, 0, 0, 0, time.Local),\n        Document:  \"02104996642\",\n        Emails:    []string{\"gabriel@test.com\", \"gabrielcataldo.231@gmail.com\", \"biel@test.org\"},\n        Balances:  []float32{10.88, 11, 13.99, 12391.23, 23321},\n        Bank:      bank,\n    }\n}    \n```\n    \nOutputs:\n\n    [INFO 2023/12/11 06:21:09] main.go:20: test mask/hide struct: {\"name\":\"Foo Bar\",\"birthDate\":\"1999-01-21T00:00:00-02:00\",\"document\":\"*****996642\",\"emails\":[\"gabriel@test.com\",\"gabrielcataldo.231@gmail.com\",\"biel@test.org\"],\"balances\":[\"10***\",\"1*\",\"13***\",\"1239****\",\"23***\"],\"bank\":{\"account\":\"123981023\",\"accountDigits\":\"123\",\"balance\":\"*****\",\"totalBalance\":200.17}}\n    [DEBUG 2023/12/11 06:21:09] main.go:21: test mask/hide struct: {\"name\":\"Foo Bar\",\"birthDate\":\"1999-01-21T00:00:00-02:00\",\"document\":\"*****996642\",\"emails\":[\"gabriel@test.com\",\"gabrielcataldo.231@gmail.com\",\"biel@test.org\"],\"balances\":[\"10***\",\"1*\",\"13***\",\"1239****\",\"23***\"],\"bank\":{\"account\":\"123981023\",\"accountDigits\":\"123\",\"balance\":\"*****\",\"totalBalance\":200.17}}\n    [WARN 2023/12/11 06:21:09] main.go:22: test mask/hide struct: {\"name\":\"Foo Bar\",\"birthDate\":\"1999-01-21T00:00:00-02:00\",\"document\":\"*****996642\",\"emails\":[\"gabriel@test.com\",\"gabrielcataldo.231@gmail.com\",\"biel@test.org\"],\"balances\":[\"10***\",\"1*\",\"13***\",\"1239****\",\"23***\"],\"bank\":{\"account\":\"123981023\",\"accountDigits\":\"123\",\"balance\":\"*****\",\"totalBalance\":200.17}}\n    [ERROR 2023/12/11 06:21:09] main.go:23: test mask/hide struct: {\"name\":\"Foo Bar\",\"birthDate\":\"1999-01-21T00:00:00-02:00\",\"document\":\"*****996642\",\"emails\":[\"gabriel@test.com\",\"gabrielcataldo.231@gmail.com\",\"biel@test.org\"],\"balances\":[\"10***\",\"1*\",\"13***\",\"1239****\",\"23***\"],\"bank\":{\"account\":\"123981023\",\"accountDigits\":\"123\",\"balance\":\"*****\",\"totalBalance\":200.17}}\n\nYou can also use functions with the ending **H** to hide all values, **MS** to mask half\ninitial half of all values, and **ME** to mask the trailing half of all values. Look:\n\n```go\nimport \"github.com/GabrielHCataldo/go-logger/logger\"\n\nfunc main() {\n    // also applies to other levels\n    msg := getBasicMsg()\n    logger.Info(msg...)\n    logger.InfoH(msg...)\n    logger.InfoMS(msg...)\n    logger.InfoME(msg...)\n}\n\nfunc getBasicMsg() []any {\n    s := []any{\n        \"text string\",\n        1,\n        12.213,\n        true,\n        nil,\n        time.Now(),\n    }\n    m := map[string]any{\n        \"int\":      1,\n        \"float\":    12.213,\n        \"string\":   \"text string\",\n        \"bool\":     true,\n        \"nilValue\": nil,\n        \"time\":     time.Now(),\n    }\n    return []any{\"basic example with any values\", \"text string\", 1, 12.213, true, time.Now(), m, s}\n}\n```\n\nOutputs:\n\n    [INFO 2023/12/11 07:19:09] main.go:5: basic example with any values text string 1 12.213 true 2023-12-11T07:19:42-03:00 {\"string\":\"text string\",\"bool\":true,\"time\":\"2023-12-11T07:19:42-03:00\",\"nilValue\":null,\"int\":1,\"float\":12.213} [\"text string\",1,12.213,true,null,\"2023-12-11T07:19:42-03:00\"]\n    [INFO 2023/12/11 07:19:09] main.go:6: ***************************** *********** * ****** **** ************************* {\"bool\":\"****\",\"time\":\"*************************\",\"nilValue\":null,\"int\":\"*\",\"float\":\"******\",\"string\":\"***********\"} [\"***********\",\"*\",\"******\",\"****\",null,\"*************************\"]\n    [INFO 2023/12/11 07:19:09] main.go:7: **************with any values *****string * ***213 **ue ************7:19:42-03:00 {\"bool\":\"**ue\",\"time\":\"************7:19:42-03:00\",\"nilValue\":null,\"int\":\"*\",\"float\":\"***213\",\"string\":\"*****string\"} [\"*****string\",\"*\",\"***213\",\"**ue\",null,\"************7:19:42-03:00\"]\n    [INFO 2023/12/11 07:19:09] main.go:8: basic example *************** text ****** * 12.*** tr** 2023-12-11T0************* {\"time\":\"2023-12-11T0*************\",\"nilValue\":null,\"int\":\"*\",\"float\":\"12.***\",\"string\":\"text ******\",\"bool\":\"tr**\"} [\"text ******\",\"*\",\"12.***\",\"tr**\",null,\"2023-12-11T0*************\"]\n\nFor total customization, you can pass opts as a parameter in functions with default **Opts**\nas already mentioned above, and you can also pass it as a global variable by calling the **SetOptions** function\nand to reset the global options to default, you can call the function **ResetOptionsToDefault**\nsee the example below:\n\n```go\nimport \"github.com/GabrielHCataldo/go-logger/logger\"\n\nfunc main() {\n    logger.SetOptions(getCustomOptionsExample())\n    msg := getBasicMsg()\n    format := \"%v, %v, %v, %v, %v, %v, %v, last is %v\"\n    logger.Info(msg...)\n    logger.ResetOptionsToDefault()\n    logger.Debug(msg...)\n    logger.WarnSkipCallerOptsf(format, 1, *getCustomOptionsExample(), msg...)\n    logger.ErrorOptsf(format, *getCustomOptionsExample(), msg...)\n}\n\nfunc getCustomOptionsExample() *logger.Options {\n    return \u0026logger.Options{\n        // Print mode (default: ModeDefault)\n        Mode:                  logger.RandomMode(),\n        // Argument date format (default: DateFormatFull24h)\n        DateFormat:            logger.RandomDateFormat(),\n        // Custom prefix text\n        CustomPrefixText: \"\",\n        // Custom after prefix text (only if Mode is ModeDefault)\n        CustomAfterPrefixText: \"\",\n        // Enable argument date to be UTC (default: false)\n        UTC:                   util.RandomBool(),\n        // Enable to not print empty message (default: false)\n        DontPrintEmptyMessage: util.RandomBool(),\n        // Enable to remove spaces between parameters (default: false)\n        RemoveSpace:           util.RandomBool(),\n        // If true will hide all datetime and prefix arguments (default: false)\n        HideAllArgs:           util.RandomBool(),\n        // If true it will hide the datetime arguments (default: false)\n        HideArgDatetime:       util.RandomBool(),\n        // If true, it will hide the caller arguments (default: false)\n        HideArgCaller:         util.RandomBool(),\n        // If true, it will disable all argument and prefix colors (default: false)\n        DisablePrefixColors:   util.RandomBool(),\n        // If true, json mode msg field becomes slice (default: false, only if Mode is ModeJson)\n        //\n        // IMPORTANT: If true, the format parameter will not work\n        EnableJsonMsgFieldForSlice: false,\n    }\n}\n\nfunc getBasicMsg() []any {\n    s := []any{\n        \"text string\",\n        1,\n        12.213,\n        true,\n        nil,\n        time.Now(),\n    }\n    m := map[string]any{\n        \"int\":      1,\n        \"float\":    12.213,\n        \"string\":   \"text string\",\n        \"bool\":     true,\n        \"nilValue\": nil,\n        \"time\":     time.Now(),\n    }\n    return []any{\"basic example with any values\", \"text string\", 1, 12.213, true, time.Now(), m, s}\n}\n```\n\nOutputs:\n\n    INFO: basic example with any valuestext string1 12.213 true2023-12-11T08:59:08-03:00{\"time\":\"2023-12-11T08:59:08-03:00\",\"nilValue\":null,\"int\":1,\"float\":12.213,\"string\":\"text string\",\"bool\":true}[\"text string\",1,12.213,true,null,\"2023-12-11T08:59:08-03:00\"]\n    [DEBUG 2023/12/11 08:59:09] types.go:194: basic example with any values text string 1 12.213 true 2023-12-11T08:59:08-03:00 {\"bool\":true,\"time\":\"2023-12-11T08:59:08-03:00\",\"nilValue\":null,\"int\":1,\"float\":12.213,\"string\":\"text string\"} [\"text string\",1,12.213,true,null,\"2023-12-11T08:59:08-03:00\"]\n    {\"level\":\"warn\",\"msg\":\"basic example with any values, text string, 1, 12.213, true, 2023-12-11T08:59:08-03:00, {\\\"nilValue\\\":null,\\\"int\\\":1,\\\"float\\\":12.213,\\\"string\\\":\\\"text string\\\",\\\"bool\\\":true,\\\"time\\\":\\\"2023-12-11T08:59:08-03:00\\\"}, last is [\\\"text string\\\",1,12.213,true,null,\\\"2023-12-11T08:59:08-03:00\\\"]\"}\n    ERROR: basic example with any values, text string, 1, 12.213, true, 2023-12-11T08:59:08-03:00, {\"nilValue\":null,\"int\":1,\"float\":12.213,\"string\":\"text string\",\"bool\":true,\"time\":\"2023-12-11T08:59:08-03:00\"}, last is [\"text string\",1,12.213,true,null,\"2023-12-11T08:59:08-03:00\"]\n\nFinally, if you want to print messages asynchronously, you can configure your global options\nor via parameter filling the **EnableAsynchronousMode** field as **true**, remembering that the information,\nfile (ex: main.go:23) are not printed in the asynchronous message, see:\n\n```go\nimport \"github.com/GabrielHCataldo/go-logger/logger\"\n\nfunc main() {\n    asyncOpt := logger.Options{EnableAsynchronousMode: true}\n    msg := getBasicMsg()\n    logger.SetOptions(\u0026asyncOpt)\n    logger.Info(msg...)\n    logger.ResetOptionsToDefault()\n    logger.InfoOpts(asyncOpt)\n}\n\nfunc getBasicMsg() []any {\n    s := []any{\n        \"text string\",\n        1,\n        12.213,\n        true,\n        nil,\n        time.Now(),\n    }\n    m := map[string]any{\n        \"int\":      1,\n        \"float\":    12.213,\n        \"string\":   \"text string\",\n        \"bool\":     true,\n        \"nilValue\": nil,\n        \"time\":     time.Now(),\n    }\n    return []any{\"basic example with any values\", \"text string\", 1, 12.213, true, time.Now(), m, s}\n}\n```\n\n#### IMPORTANT\nIn our go-logger lib we have several calls with all the examples above, always following the standards of\nnomenclature, let's explain it better:\n\n```go\nlogger.InfoSkipCallerOptsfH(\"format\", 1, opts, v...)\n```\n\nAll our calls have this priority layout by default, eliminating them according to your desire in \nAt the moment, the only mandatory name is the level, see:\n\n    logger.{level}{SkipCaller}{Opts}{f}-{H/MS/ME}\n\nExample eliminating just SkipCaller:\n\n```go\nlogger.InfoOptsfH(\"format\", opts, v...)\n```\n\nExample eliminating just Opts:\n\n```go\nlogger.InfoSkipCallerfH(\"format\", 1, v...)\n```\n\nExample eliminating only the f (format):\n\n```go\nlogger.InfoSkipCallerOptsH(1, opts, v...)\n```\n\nExample eliminating only H/MS/ME (masks):\n\n```go\nlogger.InfoSkipCallerOpts(\"format\", 1, opts, v...)\n```\n\nHow to contribute\n------\nMake a pull request, or if you find a bug, open it\nan Issues.\n\nLicense\n-------\nDistributed under MIT license, see the license file within the code for more details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrielhcataldo%2Fgo-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabrielhcataldo%2Fgo-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrielhcataldo%2Fgo-logger/lists"}