Help with logging

Hi, new here. Sorry to ask for help, but I had a developer create a Golang system for me for a specific purpose, but unfortunately they’ve since disappeared and I have a few (mainly formatting) issues to resolve and am basically learning from the start by reading the code.

At the moment, my log produces the following results:

Blockquote
|09:40:55.622|2018-10-29,2019-10-29, 2.07447ms|
|09:40:55.822|2018-10-29,2019-10-29, 2.057991ms|
|09:40:56.022|2018-10-29,2019-10-29, 2.441781ms|
|09:40:56.222|2018-10-29,2019-10-29, 2.0848ms|

I need the ‘response’ time found at the end to be in the format of 2 digits after the decimal, so that the formatting is consistent, so for example 2.07ms, 2.05ms, 2.44ms etc

I think the code to change is in this, but I’m not certain. Can anyone help?

(code provided wasn’t relevant)

As far as I can tell, the logger isn’t even used in the function you show.

Nor is there something else in the function that would write or produce a string. At least if it’s there, it is well hidden behind function calls which we can’t see into.

Does this string of code perhaps help? I really am guessing based on limited knowledge.

(code provided wasn’t relevant)

Well, not really, only thing actually logged there is the message “Processing started” with a level of debug.

On top of that, in your previous message one can see that zap is used for logging, which logs into JSON.

The exemplary output you also had in your previous post is not JSON. So its probably not related to any logging, but created somewhere else.

Yes, the “Processing started” was the only lead for me to follow, because that appears at the top of the log file before those specific date/response time reports.

This is the trouble I have with a system developed on code I’m new to, then the developer disappears and I have a ton of work for someone (might need recommendations lol).

The only other bit of code I can find is:

(code provided wasn’t relevant)

Its really hard to tell.

We do not know anything about your application, except for some code snippets that don’t tell much either.

The only thing we know is, that zap is used for actual logging, which again produces JSON output.

Next thing we know is, that you want to change the format of some printed lines that are obviously not JSON.

So from what we know so far, we can only tell, that those lines are not related to the logging part of your application.

Without full access to the code and the possibility to run it against test data, its impossible to give you any hints I think.

If you are lucky, you can use a texteditor to search via regex across all files, perhaps you can find some better hint then. "|.*|.*, .*|" this might perhaps find the place that is responsible for creating the output in question. Perhaps you need to play around a bit with that regex, but it should work as a start. But perhaps the line is created through string concatenation before just printing it… Then it will be really hard to find it without knowing how the program works…

Thanks for your help, I suspect you are right and it is produced via another means before printing. No sign of any of those entry types searching via a text editor.

I might need to get a Go ‘expert’ on board to assist in the development of the system. This change was just a minor improvement but there is greater work involved that will need full access to the code via git.

If you or anyone know of someone interested in a paid gig to help me develop the system, I’d appreciate it.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.