antigloss / go Goto Github PK
View Code? Open in Web Editor NEWgo packages
License: GNU Lesser General Public License v3.0
go packages
License: GNU Lesser General Public License v3.0
It should be possible to output logged text in the console
Run on Win32 during development
When i use the code from the example but execute the file via "go run main.go", it tries to navigate through temporary folders to save the log.
E17:39:53 logger.go:350] open ./log/C:\Users\USERNAME\AppData\Local\Temp\go-build405325394\command-line-arguments_obj\exe\main.exe.COMPUTERNAME.USERNAME.log.ERROR.20160911-608393956683: The filename, directory name, or volume label syntax is incorrect.
I used this code from the example for creation
logger.Init("./log", // specify the directory to save the logfiles
1000, // maximum logfiles allowed under the specified log directory
20, // number of logfiles to delete when number of logfiles exceeds the configured limit
50, // maximum size of a logfile in MB
false)
The problem is that the variable gProgname is being used, which is used like this
Line 521: var gProgname = path.Base(os.Args[0])
Line 289: conf.pathPrefix = conf.logPath + gProgname + "." + host + "." + username + ".log."
When using the run command, the executioning arguments change
I found the logs generated by this package are always preceded by the letter I. While at the end of the time marker there is a close bracket.
So I'm looking at the code logger.go
in function genLogPrefix
func (l *Logger) genLogPrefix(buf *buffer, logLevel int32, skip int, t time.Time) {
h, m, s := t.Clock()
// time
buf.tmp[0] = kLogLevelChar[logLevel]
surplus := 0
buf.WriteString("[") //I'm added this!
if l.flag&ControlFlagLogDate != ControlFlagNone {
year, mon, day := t.Date()
buf.nDigits(4, 1, year, '0')
buf.nDigits(2, 5, int(mon), '0')
buf.nDigits(2, 7, day, '0')
buf.tmp[9] = ' '
surplus = 9
}
//......
I added the code below on line 525
buf.WriteString("[") //I'm added this!
And the result
is this the right way or ?
Thanks in advance
Update : it turns out that char I
is the abbreviation for Info, after re-reading the code and logs.
In the console and every log file there is always a blank line after every log line (Windows). I guess there is a \n too much?!
Maybe allow to set placeholders so everybody can make the names like they want? I don't want my hostname or the file of my script in the filename of logs but others may want that.
Thanks already for consideration and the fast changes last time! ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.