增加log文件存取,以及增加LOG函数

This commit is contained in:
hoteas 2020-02-22 00:31:30 +08:00
parent bb2311148e
commit 749ee84ca3
3 changed files with 28 additions and 24 deletions

View File

@ -1,17 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="b2aca021-ff30-4cbf-8dc9-8cdd4f4c39dc" name="Default Changelist" comment="优化初步使用"> <list default="true" id="b2aca021-ff30-4cbf-8dc9-8cdd4f4c39dc" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/application.go" beforeDir="false" afterPath="$PROJECT_DIR$/application.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/const.go" beforeDir="false" afterPath="$PROJECT_DIR$/const.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/context.go" beforeDir="false" afterPath="$PROJECT_DIR$/context.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/error.go" beforeDir="false" afterPath="$PROJECT_DIR$/error.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/config/config.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/example/config/confignote.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/example/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/example/main.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/example/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/example/main.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/func.go" beforeDir="false" afterPath="$PROJECT_DIR$/func.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/func.go" beforeDir="false" afterPath="$PROJECT_DIR$/func.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/var.go" beforeDir="false" afterPath="$PROJECT_DIR$/var.go" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -90,7 +83,7 @@
<workItem from="1582182581675" duration="242000" /> <workItem from="1582182581675" duration="242000" />
<workItem from="1582182838832" duration="14000" /> <workItem from="1582182838832" duration="14000" />
<workItem from="1582292274571" duration="542000" /> <workItem from="1582292274571" duration="542000" />
<workItem from="1582294370646" duration="7170000" /> <workItem from="1582294370646" duration="8304000" />
</task> </task>
<task id="LOCAL-00001" summary="清理"> <task id="LOCAL-00001" summary="清理">
<created>1573372845218</created> <created>1573372845218</created>
@ -162,7 +155,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1582292694027</updated> <updated>1582292694027</updated>
</task> </task>
<option name="localTasksCounter" value="11" /> <task id="LOCAL-00011" summary="增加log文件存取以及增加LOG函数">
<created>1582301621585</created>
<option name="number" value="00011" />
<option name="presentableId" value="LOCAL-00011" />
<option name="project" value="LOCAL" />
<updated>1582301621585</updated>
</task>
<option name="localTasksCounter" value="12" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -188,17 +188,7 @@
<MESSAGE value="增加跨域配置,以及增加配置说明" /> <MESSAGE value="增加跨域配置,以及增加配置说明" />
<MESSAGE value="增加访问ip打印等功能" /> <MESSAGE value="增加访问ip打印等功能" />
<MESSAGE value="优化初步使用" /> <MESSAGE value="优化初步使用" />
<option name="LAST_COMMIT_MESSAGE" value="优化初步使用" /> <MESSAGE value="增加log文件存取以及增加LOG函数" />
</component> <option name="LAST_COMMIT_MESSAGE" value="增加log文件存取以及增加LOG函数" />
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/func.go</url>
<line>49</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component> </component>
</project> </project>

View File

@ -72,6 +72,7 @@ func main() {
// //
// return true // return true
//}) //})
hotime.LogError("dasdasdasdasdas")
this.Display(5, "dsadas") this.Display(5, "dsadas")
}, },
"websocket": func(this *hotime.Context) { "websocket": func(this *hotime.Context) {

17
func.go
View File

@ -29,10 +29,23 @@ import (
// return res // return res
//} //}
func LogFmt(logMsg interface{}, loglevel ...LOG_MODE) { func LogError(logMsg interface{}) {
logFmt(logMsg, 2, loglevel...) logFmt(fmt.Sprintln(logMsg), 2, LOG_ERROR)
} }
func LogWarn(logMsg interface{}) {
logFmt(fmt.Sprintln(logMsg), 2, LOG_WARN)
}
func LogInfo(logMsg ...interface{}) {
logFmt(fmt.Sprintln(logMsg), 2, LOG_INFO)
}
//func LogFmt(logMsg interface{}, loglevel ...LOG_MODE) {
//
// logFmt(logMsg, 2, loglevel...)
//}
//日志打印以及存储到文件 //日志打印以及存储到文件
func logFmt(logMsg interface{}, printLevel int, loglevel ...LOG_MODE) { func logFmt(logMsg interface{}, printLevel int, loglevel ...LOG_MODE) {