Skip to content

Commit

Permalink
Merge pull request #533 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 13.15.4
  • Loading branch information
andyone authored Dec 27, 2024
2 parents cf13574 + 99d9141 commit 7544dc7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Changelog

### [13.15.4](https://kaos.sh/ek/13.15.4)

- `[log]` Added `Levels` method which returns all supported log levels
- `[log]` `LogLevels` variable marked as deprecated
- `[fmtutil/panel]` Code refactoring

### [13.15.3](https://kaos.sh/ek/13.15.3)

- `[knf/united]` Return `errors.Errors` instead of `[]error` from `Validate`
Expand Down
10 changes: 7 additions & 3 deletions fmtutil/panel/panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,13 @@ func renderPanel(label, colorTag, title, message string, options Options) {
}

if options.Has(LABEL_POWERLINE) && !fmtc.DisableColors {
fmtc.Printf(colorTag+indent+labelFormat+colorTag+"{!} "+colorTag+"%s{!}", label, title)
fmtc.Printf(colorTag+indent+labelFormat+colorTag+"{!}", label)
} else {
fmtc.Printf(colorTag+indent+labelFormat+colorTag+" %s{!}", label, title)
fmtc.Printf(colorTag+indent+labelFormat+"{!}", label)
}

if title != "" {
fmtc.Printf(" "+colorTag+"%s{!}", title)
}

if !options.Has(TOP_LINE) {
Expand All @@ -163,7 +167,7 @@ func renderPanel(label, colorTag, title, message string, options Options) {
}
}

if options.Has(INDENT_INNER) || options.Has(BOTTOM_LINE) {
if options.Has(INDENT_INNER) {
fmtc.Println(colorTag + indent + "┃{!}")
}

Expand Down
16 changes: 16 additions & 0 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ var Colors = map[uint8]string{
}

// LogLevels is a slice with supported log level names
//
// Deprecated: Use method Levels instead
var LogLevels = []string{
"",
"debug",
Expand Down Expand Up @@ -167,6 +169,15 @@ var logLevelsNames = map[string]uint8{
"fatal": 4,
}

var logLevels = []string{
"",
"debug",
"info",
"warn", "warning",
"error",
"crit", "critical", "fatal",
}

// ////////////////////////////////////////////////////////////////////////////////// //

// New creates new logger struct
Expand Down Expand Up @@ -261,6 +272,11 @@ func Is(level uint8) bool {
return Global.Is(level)
}

// Levels returns slice with all supported log levels
func Levels() []string {
return logLevels
}

// ////////////////////////////////////////////////////////////////////////////////// //

// Reopen closes file descriptor and opens it again
Expand Down
6 changes: 4 additions & 2 deletions log/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ func (ls *LogSuite) TestErrors(c *C) {
}

func (ls *LogSuite) TestLevel(c *C) {
c.Assert(Levels(), HasLen, 9)

l := &Logger{minLevel: WARN, mu: &sync.Mutex{}}

c.Assert(l.Is(DEBUG), Equals, false)
Expand Down Expand Up @@ -486,8 +488,8 @@ func (ls *LogSuite) TestWithCaller(c *C) {

c.Assert(len(dataSlice), Equals, 3)

c.Assert(dataSlice[0][28:], Equals, "(log/log_test.go:471) Test info 1")
c.Assert(dataSlice[1][28:], Equals, "(log/log_test.go:476) Test info 2")
c.Assert(dataSlice[0][28:], Equals, "(log/log_test.go:473) Test info 1")
c.Assert(dataSlice[1][28:], Equals, "(log/log_test.go:478) Test info 2")

frm := runtime.Frame{File: "/path/to/my/app/code/test.go", Line: 10}
c.Assert(extractCallerFromFrame(frm, true), Equals, "/path/to/my/app/code/test.go:10")
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ package ek
// ////////////////////////////////////////////////////////////////////////////////// //

// VERSION is current ek package version
const VERSION = "13.15.3"
const VERSION = "13.15.4"

0 comments on commit 7544dc7

Please sign in to comment.