-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Introduced a
native/facade/value.Formatter.ColorMode
to be setta…
…ble via flags, too. 2. Removed deprecated code.
- Loading branch information
Showing
15 changed files
with
134 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package value | ||
|
||
import ( | ||
"github.com/echocat/slf4g/native/color" | ||
) | ||
|
||
// FormatterColorMode enables the access the color.Mode of a FormatterTarget. | ||
type FormatterColorMode struct { | ||
provider func() (color.Mode, bool) | ||
sink func(color.Mode) error | ||
value *color.Mode | ||
} | ||
|
||
// Set implements flag.Value. | ||
func (instance *FormatterColorMode) Set(plain string) error { | ||
var buf color.Mode | ||
if err := buf.Set(plain); err != nil { | ||
return err | ||
} | ||
|
||
if err := instance.sink(buf); err != nil { | ||
return err | ||
} | ||
|
||
instance.value = &buf | ||
return nil | ||
} | ||
|
||
func (instance FormatterColorMode) get() color.Mode { | ||
if v, ok := instance.provider(); ok { | ||
return v | ||
} | ||
if v := instance.value; v != nil { | ||
return *v | ||
} | ||
return color.ModeAuto | ||
} | ||
|
||
// Get implements flag.Getter. | ||
func (instance FormatterColorMode) Get() interface{} { | ||
return instance.get() | ||
} | ||
|
||
// String implements flag.Value. | ||
func (instance FormatterColorMode) String() string { | ||
return instance.get().String() | ||
} | ||
|
||
// Type returns the type as a string. | ||
func (instance FormatterColorMode) Type() string { | ||
return "logColorMode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters