Skip to content

Proposed minor tweaks #30

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

Merged
merged 2 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ target
gradle/
libraries/
gradlew
gradlew.bat
gradlew.bat

logs/
79 changes: 65 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,33 @@
<jar.main.class>net.juniper.netconf</jar.main.class>
</properties>

<build>
<sourceDirectory>src/main/java</sourceDirectory>
<name>${project.groupId}:${project.artifactId}</name>
<description>An API For NetConf client</description>
<url>https://github.com/Juniper/netconf-java</url>

<licenses>
<license>
<name>BSD 2</name>
<url>https://opensource.org/licenses/BSD-2-Clause</url>
</license>
</licenses>

<developers>
<developer>
<name>Juniper Staff</name>
<email>[email protected]</email>
<organization>Juniper</organization>
<organizationUrl>https://github.com/Juniper</organizationUrl>
</developer>
</developers>

<scm>
<connection>scm:git:git://github.com/Juniper/netconf-java.git</connection>
<developerConnection>scm:git:ssh://github.com:Juniper/netconf-java.git</developerConnection>
<url>https://github.com/Juniper/netconf-java/tree/master</url>
</scm>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down Expand Up @@ -59,21 +83,48 @@
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
<reportOutputDirectory>${basedir}</reportOutputDirectory>
<destDir>javadoc</destDir>
<stylesheet>java</stylesheet>
<bottom><![CDATA[Copyright 2018, <a href="https://www.juniper.net">Juniper Networks, Inc.<a>]]> </bottom>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<stylesheet>java</stylesheet>
<bottom><![CDATA[Copyright 2018, <a href="https://www.juniper.net">Juniper Networks, Inc.<a>]]> </bottom>
</configuration>
</execution>
<execution>
<id>javadoc</id>
<goals>
<goal>javadoc</goal>
</goals>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
<reportOutputDirectory>${basedir}</reportOutputDirectory>
<destDir>javadoc</destDir>
<stylesheet>java</stylesheet>
<bottom><![CDATA[Copyright 2018, <a href="https://www.juniper.net">Juniper Networks, Inc.<a>]]> </bottom>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand Down Expand Up @@ -104,7 +155,7 @@
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.12</version>
</dependency>

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/juniper/netconf/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
*/
@Slf4j
@Getter
public class Device {
public class Device implements AutoCloseable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this small change is super awesome.


private static final int DEFAULT_NETCONF_PORT = 830;
private static final int DEFAULT_TIMEOUT = 5000;
Expand Down Expand Up @@ -315,6 +315,7 @@ private boolean isSessionConnected() {
* sessions will be closed, too. Can be called at any time. Don't forget to
* call this once you don't need the device anymore.
*/
@Override
public void close() {
if (!isConnected()) {
return;
Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Root logger option
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some people, they will appreciate default logging to a file., I could imagine some others would rather leave it to themselves to configure. Currently asking some peers for their opinion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to go with it is okay. Any sane person will configure the logger on their app. I've certainly appreciated having logs their to examine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set up the properties file so that logs go to both stdout as well as a file. The top line is where the developer can change the directive:
log4j.rootLogger=DEBUG, file, stdout <-- take out file to ensure it doesn't go into a file.

But either way, yes run it by your peers. I really added it in there so that I could do some debugging on my end as I worked through your API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems fine to me to keep it there. Thanks again! The more people that use the library the more bugs we can find and fix. :)

log4j.rootLogger=DEBUG, file, stdout

# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=logs/main.log
log4j.appender.file.MaxFileSize=100MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
16 changes: 16 additions & 0 deletions src/test/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Root logger option
log4j.rootLogger=DEBUG, file, stdout

# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=logs/test.log
log4j.appender.file.MaxFileSize=100MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n