-
Notifications
You must be signed in to change notification settings - Fork 6
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
36 changed files
with
557 additions
and
161 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
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Author: fish | ||
// Author: FishGoddess | ||
// Email: [email protected] | ||
// Created at 2020/02/29 21:59:13 | ||
package main | ||
|
@@ -33,8 +33,11 @@ func main() { | |
logit.Warn("I am a warn message!") | ||
logit.Error("I am an error message!") | ||
|
||
// If you want to output log with file info, try this: | ||
logit.EnableFileInfo() | ||
// Notice that logit has blocked some methods for more refreshing method list. | ||
// If you want to use some higher level methods, you should call logit.Me() to | ||
// get the fully functional logger, then call what you want to call. | ||
// For example, if you want to output log with file info, try this: | ||
logit.Me().EnableFileInfo() | ||
logit.Info("Show file info!") | ||
|
||
// If you have a long log and it is made of many variables, try this: | ||
|
@@ -44,4 +47,7 @@ func main() { | |
r := rand.New(rand.NewSource(time.Now().Unix())) | ||
return "debug rand int: " + strconv.Itoa(r.Intn(100)) | ||
}) | ||
|
||
// If a config file "logit.conf" in "./", then logit will load it automatically. | ||
// This is more convenience to use config file and logger. | ||
} |
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Author: fish | ||
// Author: FishGoddess | ||
// Email: [email protected] | ||
// Created at 2020/03/02 20:51:29 | ||
|
||
|
@@ -30,8 +30,10 @@ import ( | |
//"go.uber.org/zap/zapcore" | ||
) | ||
|
||
// 时间格式化字符串 | ||
const timeFormat = "2006-01-02 15:04:05" | ||
const ( | ||
// 时间格式化字符串 | ||
timeFormat = "2006-01-02 15:04:05" | ||
) | ||
|
||
type nopWriter struct{} | ||
|
||
|
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Author: fish | ||
// Author: FishGoddess | ||
// Email: [email protected] | ||
// Created at 2020/03/30 14:21:28 | ||
|
||
|
@@ -44,7 +44,7 @@ func main() { | |
// } | ||
// } | ||
// | ||
logger := logit.NewLoggerFrom("./logger.conf") | ||
logger := logit.NewLoggerFromPath("./logger.conf") | ||
logger.Info("I am working!") | ||
logger.Info("My level is " + logger.Level().String()) | ||
fmt.Println("fmt ==============================================") | ||
|
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Author: fish | ||
// Author: FishGoddess | ||
// Email: [email protected] | ||
// Created at 2020/03/06 16:01:00 | ||
|
||
|
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Author: fish | ||
// Author: FishGoddess | ||
// Email: [email protected] | ||
// Created at 2020/03/01 15:10:19 | ||
|
||
|
@@ -22,20 +22,24 @@ import "github.com/FishGoddess/logit" | |
|
||
func main() { | ||
|
||
// Use logit.Debug method to output a debug level message. | ||
// Also, Info/Warn/Error method is available. | ||
logit.Debug("Default logger level is debug.") | ||
|
||
// Change logger level to info level. | ||
// So debug log will be ignored. | ||
logit.ChangeLevelTo(logit.InfoLevel) | ||
// Change logger level to info level, so logs in debug level will be ignored. | ||
// Notice that logit has blocked some methods for more refreshing method list. | ||
// If you want to use some higher level methods, you should call logit.Me() to | ||
// get the fully functional logger, then call what you want to call. | ||
logit.Me().ChangeLevelTo(logit.InfoLevel) | ||
logit.Debug("You never see me!") | ||
|
||
// In particular, you can change level to OffLevel to disable the logger. | ||
// So the info message next line will not be logged! | ||
level := logit.ChangeLevelTo(logit.OffLevel) | ||
level := logit.Me().ChangeLevelTo(logit.OffLevel) | ||
logit.Info("I will not be logged!") | ||
|
||
// Enable the Logger. | ||
// The info message next line will be logged again! | ||
logit.ChangeLevelTo(level) | ||
logit.Me().ChangeLevelTo(level) | ||
logit.Info("I am running again!") | ||
} |
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,25 @@ | ||
"handlers": { | ||
"debug": { | ||
"file": { | ||
"path": "Z:/debug.log" | ||
} | ||
}, | ||
"info": { | ||
"file": { | ||
"path": "Z:/info.log" | ||
} | ||
}, | ||
"warn": { | ||
"file": { | ||
"path": "Z:/warn.log" | ||
} | ||
}, | ||
"error": { | ||
"file": { | ||
"path": "Z:/error.log" | ||
} | ||
}, | ||
"console": { | ||
"encoder": "json" | ||
} | ||
} |
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Author: fish | ||
// Author: FishGoddess | ||
// Email: [email protected] | ||
// Created at 2020/03/03 23:39:39 | ||
|
||
|
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Author: fish | ||
// Author: FishGoddess | ||
// Email: [email protected] | ||
// Created at 2020/03/01 14:51:46 | ||
|
||
|
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Author: fish | ||
// Author: FishGoddess | ||
// Email: [email protected] | ||
// Created at 2020/03/05 17:30:21 | ||
|
||
|
Oops, something went wrong.