Skip to content

burakhalefoglu/light-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logger for production

Use this with to send the logs to Fluentbit.

Usage

package main

import (
	logger "github.com/appneuroncompany/light-logger"
    "github.com/appneuroncompany/light-logger/clogger"
    "errors"
)

func main() {
    logger.Log.App = "App name" // use this on main

    clogger.Error(&map[string]interface{}{ // use it wherever you want
        "smt err: ": errors.New("errors"),
    })

    clogger.Default(&map[string]interface{}{ // use it wherever you want
        "Default message: ": "message",
    })
        
    clogger.Info(&map[string]interface{}{ // use it wherever you want
        "Info message: ": "message",
    })

    clogger.Warning(&map[string]interface{}{ // use it wherever you want
        "Warning message: ": "message",
    })
}

This is how it will look like (will show colorful on linux terminal!):

{
        "level": "ERROR",
        "@timestamp": "2022-04-06 13:24:34",
        "@version": "1",
        "app": "App name",
        "C:/path/to/main.go:13",
        "method": "main",
        "message": {
                "smt err: ": "errors"
        }
}
{
        "level": "DEFAULT",
        "@timestamp": "2022-04-06 13:24:34",
        "@version": "1",
        "app": "App name",
        "line": "C:/path/to/main.go:17",
        "method": "main",
        "message": {
                "Default message: ": "message"
        }
}
{
        "level": "INFO",
        "@timestamp": "2022-04-06 13:24:34",
        "@version": "1",
        "app": "App name",
        "line": "C:/path/to/main.go:21",
        "method": "main",
        "message": {
                "Info message: ": "message"
        }
}
{
        "level": "WARNING",
        "@timestamp": "2022-04-06 13:24:34",
        "@version": "1",
        "app": "App name",
        "line": "C:/path/to/main.go:25",
        "method": "main",
        "message": {
                "Warning message: ": "message"
        }
}

Maintainers

Name Github
Appneuron Comapany appneuroncompany
Burak Halefoğlu burakhalefoglu
Muhammed Sarı muhammeedsari

License

Apache-2.0.