-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
87 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ jobs: | |
|
||
strategy: | ||
matrix: | ||
go_version: [1.18.x] | ||
go_version: [1.19.x] | ||
steps: | ||
|
||
- name: Set up Go 1.x | ||
|
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 |
---|---|---|
@@ -1,29 +1,29 @@ | ||
Copyright (c) 2017-2022 Gerasimos Maropoulos. | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2017-2022, Gerasimos (Makis) Maropoulos ([email protected]) | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following disclaimer | ||
in the documentation and/or other materials provided with the | ||
distribution. | ||
* Neither the name of golog nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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 |
---|---|---|
@@ -1,53 +1,52 @@ | ||
/* | ||
Copyright (c) 2017-2021 Gerasimos Maropoulos. | ||
CBSD 3-Clause License | ||
Copyright (c) 2017-2022, Gerasimos (Makis) Maropoulos ([email protected]) | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following disclaimer | ||
in the documentation and/or other materials provided with the | ||
distribution. | ||
* Neither the name of golog nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
modification, are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
/* | ||
Package golog provides an easy to use foundation for your logging operations. | ||
Source code and other details for the project are available at GitHub: | ||
https://github.com/kataras/golog | ||
https://github.com/kataras/golog | ||
Current Version | ||
# Current Version | ||
0.1.7 | ||
0.1.8 | ||
Installation | ||
# Installation | ||
The only requirement is the Go Programming Language | ||
$ go get -u github.com/kataras/golog | ||
Overview | ||
$ go get github.com/kataras/golog@latest | ||
# Overview | ||
Example code: | ||
|
@@ -77,10 +76,7 @@ Example code: | |
golog.Debug("This is a debug message") | ||
} | ||
New | ||
# New | ||
Golog has a default, package-level initialized instance for you, | ||
however you can choose to create and use a logger instance for a | ||
|
@@ -112,12 +108,11 @@ Example Code: | |
log.Debug("This is a debug message") | ||
} | ||
Format | ||
# Format | ||
Golog sets colors to levels when its `Printer.Output` is actual a compatible terminal | ||
which can renders colors, otherwise it will downgrade itself to a white foreground. | ||
Golog has functions to print a formatted log too. | ||
Example Code: | ||
|
@@ -127,24 +122,21 @@ Example Code: | |
golog.Errorf("[%d] This is an info %s", 1, "formatted log") | ||
golog.Debugf("[%d] This is an info %s", 1, "formatted log") | ||
Output | ||
# Output | ||
Golog takes a simple `io.Writer` as its underline Printer's Output. | ||
Example Code: | ||
golog.SetOutput(io.Writer) | ||
You can even override the default line braker, "\n", by using the `golog#NewLine` function at startup. | ||
Example Code: | ||
golog.NewLine("\r\n") | ||
Levels | ||
# Levels | ||
Golog is a leveled logger, therefore you can set a level and print | ||
whenever the print level is valid with the set-ed one. | ||
|
@@ -162,14 +154,12 @@ Available built'n levels are: | |
// DebugLevel will print on any level, errors, warnings, infos and debug messages | ||
DebugLevel | ||
Below you'll learn a way to add a custom level or modify an existing level. | ||
The default colorful text(or raw text for unsupported outputs) for levels | ||
can be overridden by using the `golog#ErrorText, golog#WarnText, golog#InfoText and golog#DebugText` | ||
functions. | ||
Example Code: | ||
package main | ||
|
@@ -203,10 +193,8 @@ Example Code: | |
golog.Debug("This is a debug message") | ||
} | ||
Golog gives you the power to add or modify existing levels is via Level Metadata. | ||
Example Code: | ||
package main | ||
|
@@ -248,12 +236,10 @@ Example Code: | |
myLogger.Logf(SuccessLevel, "This is a success log message with green color") | ||
} | ||
The logger's level can be changed via passing one of the | ||
level constants to the `Level` field or by | ||
passing its string representation to the `SetLevel` function. | ||
Example Code: | ||
golog.SetLevel("disable") | ||
|
@@ -263,8 +249,7 @@ Example Code: | |
golog.SetLevel("info") | ||
golog.SetLevel("debug") | ||
Integrations | ||
# Integrations | ||
Transaction with your favorite, but deprecated logger is easy. | ||
Golog offers two basic interfaces, the `ExternalLogger` and the `StdLogger` | ||
|
@@ -300,8 +285,7 @@ Outline: | |
// Look `golog#Handle` for more. | ||
InstallStd(logger StdLogger) | ||
Logrus Integration | ||
# Logrus Integration | ||
Example Code: | ||
|
@@ -348,8 +332,7 @@ Example Code: | |
golog.Error("this error message will be visible as text") | ||
} | ||
Standard `log.Logger` Integration | ||
# Standard `log.Logger` Integration | ||
Example Code: | ||
|
@@ -377,8 +360,7 @@ Example Code: | |
golog.Warn("this info message will not be visible") | ||
} | ||
That's the basics | ||
# That's the basics | ||
But you should have a basic idea of the golog package by now, we just scratched the surface. | ||
If you enjoy what you just saw and want to learn more, please follow the below links: | ||
|
@@ -390,4 +372,4 @@ Examples: | |
package golog | ||
|
||
// Version is the version string representation of the "golog" package. | ||
const Version = "0.1.7" | ||
const Version = "0.1.8" |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/kataras/golog | ||
|
||
go 1.18 | ||
go 1.19 | ||
|
||
require github.com/kataras/pio v0.0.11 | ||
|
||
|
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
Oops, something went wrong.