swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

Provide logger instead of sys outs.

Open sbelan opened this issue 10 years ago • 14 comments

Hi, During client code generation getting below sysouts. It would be great if you provide logger instead of sysouts.

Sysout: reading from.... writing file

sbelan avatar Feb 22 '16 06:02 sbelan

I believe we've done that already. Are you using the latest master?

wing328 avatar Feb 22 '16 06:02 wing328

@wing328 Just checked master. Writing file sysout removed but reading from sys out still present at line no 77 for Swagger20Parser.java https://github.com/swagger-api/swagger-parser/blob/master/modules/swagger-parser/src/main/java/io/swagger/parser/Swagger20Parser.java

sbelan avatar Feb 22 '16 07:02 sbelan

May I know if you've cycle to submit a PR for that?

wing328 avatar Feb 22 '16 07:02 wing328

@wing328 ... If I will get time on coming weekend Will let you know..

sbelan avatar Feb 22 '16 12:02 sbelan

@sbelan do you need help submitting the PR?

wing328 avatar Mar 07 '16 02:03 wing328

@wing328 ...hey sorry for the delay..was busy with other issues. Will surely do on coming weekend and let you know if any help requires.

sbelan avatar Mar 09 '16 06:03 sbelan

@wing328 ... I am doing this first time... I followed below steps.

  1. Forked master
  2. Changed java unit

Right now I want to test it before submit the PR. Please let me know, Is there any guideline for testing? Also share me link for PR submit process.

sbelan avatar Mar 12 '16 16:03 sbelan

@wing328 ... I did testing using > mvn test. During testing I found one more issue as below, because of this debug statements are not coming: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

To fix this, I have added

slf4j-simple jar.

http://www.slf4j.org/manual.html After that I am able to see my logs. Please find attached files for test report. After_Fix_Test_Report.txt BeforeFix_Test_Report.txt IssueFix_Test_Report_DebugEnabled.txt

sbelan avatar Mar 13 '16 06:03 sbelan

@wing328 ... one more observation from my side when digging out code. As we are using slf4j facade then we don't need to check System.getProperty("debugParser") for each info statements, instead of this we can use formatting param method > {} provided by sl4fJ. Below is the example:

logger.debug("Value {} was inserted between {} and {}.", newVal, below, above);

http://www.slf4j.org/faq.html#logging_performance

sbelan avatar Mar 13 '16 06:03 sbelan

RE: 1. Forked master

Are you referring to the master of Swagger Parser (https://github.com/swagger-api/swagger-parser)?

wing328 avatar Mar 15 '16 07:03 wing328

RE: http://www.slf4j.org/faq.html#logging_performance

The URL is broken.

wing328 avatar Mar 15 '16 07:03 wing328

@wing328 ...

  1. Yes I am referring the master of swagger parser
  2. I am able to access above URL. Other way you can tray like goto http://www.slf4j.org/ then ---> documentation --> FAQ --> then Question --> What is the fastest way of (not) logging?

sbelan avatar Mar 15 '16 08:03 sbelan

@wing328 any update.?

sbelan avatar Mar 19 '16 13:03 sbelan

I would suggest you to open a PR with swagger-parser and ask for more guidance there.

wing328 avatar Mar 19 '16 13:03 wing328