Add license and fix READMEs

Signed-off-by: jolheiser <john.olheiser@gmail.com>
pull/3/head v1.1.0-rc1
jolheiser 2020-10-18 17:00:45 -05:00
parent 16a913dfb9
commit d94c70e319
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
3 changed files with 19 additions and 29 deletions

7
LICENSE 100644
View File

@ -0,0 +1,7 @@
Copyright 2020 John Olheiser
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -50,4 +50,8 @@ Beaver allows you to customize the colors of various parts of the message
color.Trace = color.New(color.FgMagenta)
```
[More info for the `color` package](color/README.md)
[More info for the `color` package](color/README.md)
## LICENSE
[MIT](LICENSE)

View File

@ -2,6 +2,9 @@
Beaver comes with the `color` sub-package that can be used even without Beaver calls.
`Color` is an interface that simply needs `Format(text string) string` to fulfill it.
Any logger in beaver can be set to a `Color`.
## Formatting a string with a single attribute
```go
text := color.FgRed.Format("red")
@ -12,34 +15,10 @@ text := color.FgRed.Format("red")
text := color.New(color.BgGreen, color.FgRed, color.Bold).Format("green background, red text, and bold")
```
## Formatting strings with multiple colors
The following are different ways to print `This is a color test!`
where the word `color` is red while everything else is `green`.
## Extended colors
### setup
Assuming each example is preceded by
```go
green := color.New(color.FgGreen)
red := color.New(color.FgRed)
```
Extended colors are 256-color extensions. They can be referred to by name, available in [extended_colors.go](extended_colors.go).
#### pure `fmt.Println`
```go
fmt.Println(green.Format("This is a"), red.Format("color"), green.Format("test!"))
```
## True colors
#### `color.Wrap`
```go
fmt.Println(green.Wrap("This is a #{color} test!", red))
```
#### string formatting with `fmt.Printf` and `color.Wrap`
```go
fmt.Printf(green.Wrap("This is a #{%s} test!\n", red), "color")
```
#### using a different directive prefix
```go
color.DirectivePrefix('$')
fmt.Printf(green.Wrap("This is a ${%s} test!\n", red), "color")
```
True colors are full RBG colors, they can be either created with RGB values or parsed from hex.