Giter Club home page Giter Club logo

go's People

Contributors

antigloss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go's Issues

Logger is not working when using "go run"

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

Square Open Bracket instead I char In Logger

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.
image
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
image
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.

Empty line in 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?!

Logging file format

  • The date part should come first in the filename, so that its possible to order the files alphabetically and immediately jump to the right day
  • The log files should not contain nanoseconds

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! ๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.