Coder Social home page Coder Social logo

slf4go's People

Contributors

jrwren avatar kaiaush avatar lrweck avatar sisyphsu avatar xanderatbackbonesystems avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

slf4go's Issues

Possible typo in fatal logger name

When looking at the constant names in slf_model.go, I noticed that the fatal level name has only a single "L". It is spelled as "Fata" and "Level" combined. This is confusing when compared with the names of the other levels.

const (
	TraceLevel Level = iota
	DebugLevel
	InfoLevel
	WarnLevel
	ErrorLevel
	PanicLevel
	FataLevel
)

I suggest that another constant be added called FatalLevel with the same numeric value as FataLevel.

Allow to store and retrieve logger in `context.Context` object

The standard Golang context.Context allows storing and retrieve objects using WithValue and Value func.

It would be a good idea to create a common API to configure slf4go using context.Context API, apart from existing usage of global variable. The current approach of using global variables (globalLogger, and globalDriver) are not always acceptable in some projects, as it's susceptible to race conditions to occur.

An example of a new API:

// configure logger: driver, level, etc. withing context
d := slogzap.Driver{/* ... */}
ctx = slog.WithLogger(ctx, slog.Config{Driver: d})

// usage
func someUserFunc(ctx context.Context) {
  log := slog.FromContext(ctx)
  log.Info("Example msg")
}

Errors when using current go.mod (and dependencies)

When simply importing module
import slog "github.com/go-eden/slf4go"

and using the following
slog.SetLevel(slog.InfoLevel)
slog.Debug("Don't see this")
slog.Info("DO see this")

Here are the errors

github.com/go-eden/etime

C:\Go_Projs\pkg\mod\github.com\go-eden\[email protected]\etime_now.go:19:11: cannot use tv.Sec (type int32) as type int64 in return argument
C:\Go_Projs\pkg\mod\github.com\go-eden\[email protected]\etime_now.go:33:20: invalid operation: tv.Sec * 1000 + int64(tv.Usec) / 1000 (mismatched types int32 and int64)
C:\Go_Projs\pkg\mod\github.com\go-eden\[email protected]\etime_now.go:47:20: invalid operation: tv.Sec * 1e+06 + int64(tv.Usec) (mismatched types int32 and int64)

github.com/huandu/go-tls

C:\Go_Projs\pkg\mod\github.com\huandu\[email protected]\syscall_unix.go:17:17: undefined: syscall.PROT_NONE
C:\Go_Projs\pkg\mod\github.com\huandu\[email protected]\syscall_unix.go:18:17: undefined: syscall.PROT_READ
C:\Go_Projs\pkg\mod\github.com\huandu\[email protected]\syscall_unix.go:19:17: undefined: syscall.PROT_WRITE
C:\Go_Projs\pkg\mod\github.com\huandu\[email protected]\syscall_unix.go:20:17: undefined: syscall.PROT_EXEC
C:\Go_Projs\pkg\mod\github.com\huandu\[email protected]\syscall_unix.go:30:32: not enough arguments in call to syscall.Syscall
C:\Go_Projs\pkg\mod\github.com\huandu\[email protected]\syscall_unix.go:30:33: undefined: syscall.SYS_MPROTECT

No method available to add Fields to existing globalLogger variable

HI,
I want to add few values to Fields of the exiting globalLogger, not to the new one created by GetLogger() or func NewLogger(name string) . because I see that no possiblity to again set back newly created *Logger to globalLogger variable.
This is also becasue , slf_core.go always uses globalLogger & not the one I created instance of Logger

func Debug(v ...interface{}) {
...
...
globalLogger.print(DebugLevel, pc[0], nil, v...)
}

Either provide a method to set the newly created Logger to globalLogger or provide new getGlobalLogger() to get handle to globalLogger so that Fields can be added.

somethig like below in slf_core.go :

func GetGlobalLogger() *Logger {
return globalLogger
}

OR

func AddFields(fields Fields) {
globalLogger.BindFields(fields Fields)
}

Default example does not work on version 1.0.9

Hi,

the default example does not work on the 1.0.9 version. There are no logs.

The version 1.0.8 works like expected.

2021-05-24 11:40:06.722457 [1] [DEBUG] [root] log.go:12 debug time: 2021-05-24 11:40:06.722442165 +0200 CEST m=+0.000102399
2021-05-24 11:40:06.722631 [1] [WARN ] [root] log.go:15 warn log
2021-05-24 11:40:06.722644 [1] [ERROR] [root] log.go:17 error log
2021-05-24 11:40:06.722679 [1] [PANIC] [root] log.go:20 panic time: 2021-05-24 11:40:06.722651348 +0200 CEST m=+0.000311567
goroutine 1 [running]:
runtime/debug.Stack(0x4b55e0, 0xc00009e370, 0x1)
        /usr/local/go/src/runtime/debug/stack.go:24 +0x9f
github.com/go-eden/slf4go.Panicf(0x4d1c4d, 0xe, 0xc00009e360, 0x1, 0x1)
        /home/andrej/go/pkg/mod/github.com/go-eden/[email protected]/slf_core.go:210 +0x8e
main.main()
        /home/andrej/go/src/github.com/lorislab/tmp/log.go:20 +0x1f9

br,
Andrej

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.