icexin / eggos

A Go unikernel running on x86 bare metal
http://eggos.icexin.com
MIT License
2.23k stars 113 forks source link

Allow eggos implementations to programatically set log levels #96

Closed jspc closed 2 years ago

jspc commented 2 years ago

When running applications on platforms where there is no environment, calls to os.Setenv to set a loglevel have inconsistent results. Similarly, setting this environment variable before the first log event, and thus making that call moot, is racy.

Instead, then, export log levels, drop the potential stutter in log.LogLvl to log.Level, and allow implementations/ callers of this package to set a log level accordingly, while maintaining the default behaviour

jspc commented 2 years ago

@icexin :recycle:

I've written a setter with bounds checking (with some tests) and made it accept an explicit log level type. I've left the init() function alone, so it still sets log.Level directly, since it does it's own bounds checking1