-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reformat timestamps in factorio log #181
base: develop
Are you sure you want to change the base?
Reformat timestamps in factorio log #181
Conversation
If im understanding that correctly: In my logs i find this lineformat exactly once, so im not sure, if this is really something we need. If you have this often, just write so and change my mind about needing this. Also a Please use develop as base branch and merge it into your PR branch. |
Thanks for your feedback. I will look into it asap and improve my code. As for my deployment of the server manager, I get only lines like this:
Which look like this with my code (line numbers in reverse because I pasted the above from the actual log file):
Your example above is from the chat for me these lines are only in the actual server log and are missing in the server manager ui. Maybe this all has to do with the deployment on my side, idk. It is very basic on a debian server in a docker container. I am using the Dockerfile from the repo. As I said already, I also think it would be nice to have a switch to toggle this feature so that everybody can see the actual logs if needed. But I have no problem if this is something only I need. Then I will just use it for my own. |
a23bd9a
to
6a87670
Compare
I rebased my branch from I would really appreciate, if you would look at it once again 🙂 |
ok, that makes sense and i like the addition now 😃 Since it is your first go program, this is something, that should be done with every go-code: run Since you replace the timestamps, that factorio uses to a timestamp, the information about the milliseconds get lost. Therefore i would like to see the ms too, so add them to your timestamp or keep the factorio-output in brackets. Additional, should we implement that for the Cnosole too? I would say yes, but one after another. I would merge this PR and you create a new one for the Console 😉 |
src/gamelog.go
Outdated
|
||
// set this to toggle log reformat of timestamps | ||
var reformatTimestampsEnabled = true | ||
|
||
func tailLog(filename string) ([]string, error) { | ||
result := []string{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace empty slice with nil-slice
result := []string{}
-> var result []string
src/gamelog.go
Outdated
|
||
func reformatTimestamps(log []string) ([]string) { | ||
getStartTime(log) | ||
result := []string{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, replace empty slice to nil-slice
src/gamelog.go
Outdated
|
||
func getStartTime(log []string) { | ||
re, _ := regexp.Compile(`\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}`) | ||
date := string(re.FindString(log[0])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convertion from string to string not needed
src/gamelog.go
Outdated
getStartTime(log) | ||
result := []string{} | ||
|
||
for i := range log { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use key-value for loop: for index, line := range log {
or in this case for _, line := range log {
, since you dont need the index.
6a87670
to
7ca4363
Compare
While using your very useful server manager, it always bothered me that you can't see the real date/time in the log file.
Today I realized, that this has nothing to do with your software but with the format factorio stores the logs in. So I made this PR to reformat the log.
Maybe we could also implement a switch to toggle this feature. But as this would be part of the frontend and I do not know a lot about react, I will leave it as is.
This is my first code in go, so I am very open for suggestions depending code quality and style. Of course any other suggestions are welcome as well.
Hope to see this in upstream soon.