You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package LogUtil
import (
"dsSso/Utils/CommonUtil"
"log"
"os"
)
/**
功能:记录错误信息
作者:黄海
时间: 2020-03-24
*/
func Error ( code string , msg string ) {
//判断是不是单元测试,如果是的话,那么配置文件的路径需要加上一个.
var logPath = "./Logs"
//判断文件不是存在(用于兼容单元测试不同的目录结构)
if ! CommonUtil . Exists ( logPath ) {
logPath = "." + logPath
}
if ! CommonUtil . Exists ( logPath ) {
//创建
os . Mkdir ( logPath , os . ModePerm )
}
//设置手工日志的办法
logFile , err := os . OpenFile ( logPath + "/dsSso.log" , os . O_WRONLY | os . O_CREATE | os . O_APPEND , 0644 )
defer logFile . Close ( )
if err != nil {
log . Fatalln ( "open file error !" )
}
// 创建一个日志对象
debugLog := log . New ( logFile , "[Error]" , log . LstdFlags )
debugLog . Println ( code , "\t" , msg )
}