Use Logger instead of println #126

Merged
StoneLabs merged 4 commits from patch-1 into 1.17 2021-09-22 11:25:04 +00:00
2 changed files with 2 additions and 2 deletions
Showing only changes of commit cca1e7dab3 - Show all commits

View File

@ -14,6 +14,6 @@ public class ExampleMod implements ModInitializer {
modmuss50 commented 2021-09-21 11:58:06 +00:00 (Migrated from github.com)
Review

Why not LOGGER.info("Hello Fabric world!")?

Why not `LOGGER.info("Hello Fabric world!")`?
modmuss50 commented 2021-09-21 11:58:06 +00:00 (Migrated from github.com)
Review

Why not LOGGER.info("Hello Fabric world!")?

Why not `LOGGER.info("Hello Fabric world!")`?
StoneLabs commented 2021-09-21 11:59:05 +00:00 (Migrated from github.com)
Review

Would be fine with me, i just thought this would more obviously hint towards other options besides INFO.

Should i change it?

Would be fine with me, i just thought this would more obviously hint towards other options besides INFO. Should i change it?
StoneLabs commented 2021-09-21 11:59:05 +00:00 (Migrated from github.com)
Review

Would be fine with me, i just thought this would more obviously hint towards other options besides INFO.

Should i change it?

Would be fine with me, i just thought this would more obviously hint towards other options besides INFO. Should i change it?
modmuss50 commented 2021-09-21 12:00:57 +00:00 (Migrated from github.com)
Review

I would, I generally dont pass the level like that in a case like this.

I would, I generally dont pass the level like that in a case like this.
modmuss50 commented 2021-09-21 12:00:57 +00:00 (Migrated from github.com)
Review

I would, I generally dont pass the level like that in a case like this.

I would, I generally dont pass the level like that in a case like this.
StoneLabs commented 2021-09-21 12:02:05 +00:00 (Migrated from github.com)
Review

Alright, give me a minute.

Alright, give me a minute.
StoneLabs commented 2021-09-21 12:02:05 +00:00 (Migrated from github.com)
Review

Alright, give me a minute.

Alright, give me a minute.
Technici4n commented 2021-09-21 12:36:52 +00:00 (Migrated from github.com)
Review

Might want to give the logger a name, for example LogManager.getLogger("ExampleMod").

Might want to give the logger a name, for example `LogManager.getLogger("ExampleMod")`.
Technici4n commented 2021-09-21 12:36:52 +00:00 (Migrated from github.com)
Review

Might want to give the logger a name, for example LogManager.getLogger("ExampleMod").

Might want to give the logger a name, for example `LogManager.getLogger("ExampleMod")`.
StoneLabs commented 2021-09-21 12:45:09 +00:00 (Migrated from github.com)
Review

By default, the getLogger will use the Caller's class name. So that would be ExampleMod anyways.

// Returns a Logger with the name of the calling class.
// Returns:
//     The Logger for the calling class.
// Throws:
//     UnsupportedOperationException – if the calling class cannot be determined.
public static Logger getLogger() {
    return getLogger(StackLocatorUtil.getCallerClass(2));
}
By default, the getLogger will use the Caller's class name. So that would be ExampleMod anyways. ```java // Returns a Logger with the name of the calling class. // Returns: // The Logger for the calling class. // Throws: // UnsupportedOperationException – if the calling class cannot be determined. public static Logger getLogger() { return getLogger(StackLocatorUtil.getCallerClass(2)); } ```
StoneLabs commented 2021-09-21 12:45:09 +00:00 (Migrated from github.com)
Review

By default, the getLogger will use the Caller's class name. So that would be ExampleMod anyways.

// Returns a Logger with the name of the calling class.
// Returns:
//     The Logger for the calling class.
// Throws:
//     UnsupportedOperationException – if the calling class cannot be determined.
public static Logger getLogger() {
    return getLogger(StackLocatorUtil.getCallerClass(2));
}
By default, the getLogger will use the Caller's class name. So that would be ExampleMod anyways. ```java // Returns a Logger with the name of the calling class. // Returns: // The Logger for the calling class. // Throws: // UnsupportedOperationException – if the calling class cannot be determined. public static Logger getLogger() { return getLogger(StackLocatorUtil.getCallerClass(2)); } ```
liach commented 2021-09-21 14:29:07 +00:00 (Migrated from github.com)
Review

Imo we should use the mod id for the logger name.

Imo we should use the mod id for the logger name.
liach commented 2021-09-21 14:29:07 +00:00 (Migrated from github.com)
Review

Imo we should use the mod id for the logger name.

Imo we should use the mod id for the logger name.
sfPlayer1 commented 2021-09-21 19:35:29 +00:00 (Migrated from github.com)
Review

Yes, definitely mod id. It is the most useful for the end user and we want to promote best practices.

Yes, definitely mod id. It is the most useful for the end user and we want to promote best practices.
sfPlayer1 commented 2021-09-21 19:35:29 +00:00 (Migrated from github.com)
Review

Yes, definitely mod id. It is the most useful for the end user and we want to promote best practices.

Yes, definitely mod id. It is the most useful for the end user and we want to promote best practices.
StoneLabs commented 2021-09-21 21:33:16 +00:00 (Migrated from github.com)
Review

@sfPlayer1 How would I get the mod id? Or do you mean LogManager.getLogger("modid")?

@sfPlayer1 How would I get the mod id? Or do you mean `LogManager.getLogger("modid")`?
StoneLabs commented 2021-09-21 21:33:16 +00:00 (Migrated from github.com)
Review

@sfPlayer1 How would I get the mod id? Or do you mean LogManager.getLogger("modid")?

@sfPlayer1 How would I get the mod id? Or do you mean `LogManager.getLogger("modid")`?
sfPlayer1 commented 2021-09-21 21:38:17 +00:00 (Migrated from github.com)
Review

Yes, but please add a comment to encourage using the actual mod id. I may add something to Loader to determine it from a class eventually, but for now it's not really supported.

Yes, but please add a comment to encourage using the actual mod id. I may add something to Loader to determine it from a class eventually, but for now it's not really supported.
sfPlayer1 commented 2021-09-21 21:38:17 +00:00 (Migrated from github.com)
Review

Yes, but please add a comment to encourage using the actual mod id. I may add something to Loader to determine it from a class eventually, but for now it's not really supported.

Yes, but please add a comment to encourage using the actual mod id. I may add something to Loader to determine it from a class eventually, but for now it's not really supported.
StoneLabs commented 2021-09-21 21:47:40 +00:00 (Migrated from github.com)
Review

How does this sound?

// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LogManager.getLogger("modid");
How does this sound? ```java // This logger is used to write text to the console and the log file. // It is considered best practice to use your mod id as the logger's name. // That way, it's clear which mod wrote info, warnings, and errors. public static final Logger LOGGER = LogManager.getLogger("modid"); ```
StoneLabs commented 2021-09-21 21:47:40 +00:00 (Migrated from github.com)
Review

How does this sound?

// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LogManager.getLogger("modid");
How does this sound? ```java // This logger is used to write text to the console and the log file. // It is considered best practice to use your mod id as the logger's name. // That way, it's clear which mod wrote info, warnings, and errors. public static final Logger LOGGER = LogManager.getLogger("modid"); ```
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
LOGGER.log(Level.INFO, "Hello Fabric world!");
modmuss50 commented 2021-09-21 11:58:06 +00:00 (Migrated from github.com)
Review

Why not LOGGER.info("Hello Fabric world!")?

Why not `LOGGER.info("Hello Fabric world!")`?
StoneLabs commented 2021-09-21 11:59:05 +00:00 (Migrated from github.com)
Review

Would be fine with me, i just thought this would more obviously hint towards other options besides INFO.

Should i change it?

Would be fine with me, i just thought this would more obviously hint towards other options besides INFO. Should i change it?
modmuss50 commented 2021-09-21 12:00:57 +00:00 (Migrated from github.com)
Review

I would, I generally dont pass the level like that in a case like this.

I would, I generally dont pass the level like that in a case like this.
StoneLabs commented 2021-09-21 12:02:05 +00:00 (Migrated from github.com)
Review

Alright, give me a minute.

Alright, give me a minute.
Technici4n commented 2021-09-21 12:36:52 +00:00 (Migrated from github.com)
Review

Might want to give the logger a name, for example LogManager.getLogger("ExampleMod").

Might want to give the logger a name, for example `LogManager.getLogger("ExampleMod")`.
StoneLabs commented 2021-09-21 12:45:09 +00:00 (Migrated from github.com)
Review

By default, the getLogger will use the Caller's class name. So that would be ExampleMod anyways.

// Returns a Logger with the name of the calling class.
// Returns:
//     The Logger for the calling class.
// Throws:
//     UnsupportedOperationException – if the calling class cannot be determined.
public static Logger getLogger() {
    return getLogger(StackLocatorUtil.getCallerClass(2));
}
By default, the getLogger will use the Caller's class name. So that would be ExampleMod anyways. ```java // Returns a Logger with the name of the calling class. // Returns: // The Logger for the calling class. // Throws: // UnsupportedOperationException – if the calling class cannot be determined. public static Logger getLogger() { return getLogger(StackLocatorUtil.getCallerClass(2)); } ```
liach commented 2021-09-21 14:29:07 +00:00 (Migrated from github.com)
Review

Imo we should use the mod id for the logger name.

Imo we should use the mod id for the logger name.
sfPlayer1 commented 2021-09-21 19:35:29 +00:00 (Migrated from github.com)
Review

Yes, definitely mod id. It is the most useful for the end user and we want to promote best practices.

Yes, definitely mod id. It is the most useful for the end user and we want to promote best practices.
StoneLabs commented 2021-09-21 21:33:16 +00:00 (Migrated from github.com)
Review

@sfPlayer1 How would I get the mod id? Or do you mean LogManager.getLogger("modid")?

@sfPlayer1 How would I get the mod id? Or do you mean `LogManager.getLogger("modid")`?
sfPlayer1 commented 2021-09-21 21:38:17 +00:00 (Migrated from github.com)
Review

Yes, but please add a comment to encourage using the actual mod id. I may add something to Loader to determine it from a class eventually, but for now it's not really supported.

Yes, but please add a comment to encourage using the actual mod id. I may add something to Loader to determine it from a class eventually, but for now it's not really supported.
StoneLabs commented 2021-09-21 21:47:40 +00:00 (Migrated from github.com)
Review

How does this sound?

// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LogManager.getLogger("modid");
How does this sound? ```java // This logger is used to write text to the console and the log file. // It is considered best practice to use your mod id as the logger's name. // That way, it's clear which mod wrote info, warnings, and errors. public static final Logger LOGGER = LogManager.getLogger("modid"); ```
LOGGER.info("Hello Fabric world!");
modmuss50 commented 2021-09-21 11:58:06 +00:00 (Migrated from github.com)
Review

Why not LOGGER.info("Hello Fabric world!")?

Why not `LOGGER.info("Hello Fabric world!")`?
StoneLabs commented 2021-09-21 11:59:05 +00:00 (Migrated from github.com)
Review

Would be fine with me, i just thought this would more obviously hint towards other options besides INFO.

Should i change it?

Would be fine with me, i just thought this would more obviously hint towards other options besides INFO. Should i change it?
modmuss50 commented 2021-09-21 12:00:57 +00:00 (Migrated from github.com)
Review

I would, I generally dont pass the level like that in a case like this.

I would, I generally dont pass the level like that in a case like this.
StoneLabs commented 2021-09-21 12:02:05 +00:00 (Migrated from github.com)
Review

Alright, give me a minute.

Alright, give me a minute.
Technici4n commented 2021-09-21 12:36:52 +00:00 (Migrated from github.com)
Review

Might want to give the logger a name, for example LogManager.getLogger("ExampleMod").

Might want to give the logger a name, for example `LogManager.getLogger("ExampleMod")`.
StoneLabs commented 2021-09-21 12:45:09 +00:00 (Migrated from github.com)
Review

By default, the getLogger will use the Caller's class name. So that would be ExampleMod anyways.

// Returns a Logger with the name of the calling class.
// Returns:
//     The Logger for the calling class.
// Throws:
//     UnsupportedOperationException – if the calling class cannot be determined.
public static Logger getLogger() {
    return getLogger(StackLocatorUtil.getCallerClass(2));
}
By default, the getLogger will use the Caller's class name. So that would be ExampleMod anyways. ```java // Returns a Logger with the name of the calling class. // Returns: // The Logger for the calling class. // Throws: // UnsupportedOperationException – if the calling class cannot be determined. public static Logger getLogger() { return getLogger(StackLocatorUtil.getCallerClass(2)); } ```
liach commented 2021-09-21 14:29:07 +00:00 (Migrated from github.com)
Review

Imo we should use the mod id for the logger name.

Imo we should use the mod id for the logger name.
sfPlayer1 commented 2021-09-21 19:35:29 +00:00 (Migrated from github.com)
Review

Yes, definitely mod id. It is the most useful for the end user and we want to promote best practices.

Yes, definitely mod id. It is the most useful for the end user and we want to promote best practices.
StoneLabs commented 2021-09-21 21:33:16 +00:00 (Migrated from github.com)
Review

@sfPlayer1 How would I get the mod id? Or do you mean LogManager.getLogger("modid")?

@sfPlayer1 How would I get the mod id? Or do you mean `LogManager.getLogger("modid")`?
sfPlayer1 commented 2021-09-21 21:38:17 +00:00 (Migrated from github.com)
Review

Yes, but please add a comment to encourage using the actual mod id. I may add something to Loader to determine it from a class eventually, but for now it's not really supported.

Yes, but please add a comment to encourage using the actual mod id. I may add something to Loader to determine it from a class eventually, but for now it's not really supported.
StoneLabs commented 2021-09-21 21:47:40 +00:00 (Migrated from github.com)
Review

How does this sound?

// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LogManager.getLogger("modid");
How does this sound? ```java // This logger is used to write text to the console and the log file. // It is considered best practice to use your mod id as the logger's name. // That way, it's clear which mod wrote info, warnings, and errors. public static final Logger LOGGER = LogManager.getLogger("modid"); ```
}
}

modmuss50 commented 2021-09-21 11:58:06 +00:00 (Migrated from github.com)
Review

Why not LOGGER.info("Hello Fabric world!")?

Why not `LOGGER.info("Hello Fabric world!")`?
modmuss50 commented 2021-09-21 11:58:06 +00:00 (Migrated from github.com)
Review

Why not LOGGER.info("Hello Fabric world!")?

Why not `LOGGER.info("Hello Fabric world!")`?
StoneLabs commented 2021-09-21 11:59:05 +00:00 (Migrated from github.com)
Review

Would be fine with me, i just thought this would more obviously hint towards other options besides INFO.

Should i change it?

Would be fine with me, i just thought this would more obviously hint towards other options besides INFO. Should i change it?
StoneLabs commented 2021-09-21 11:59:05 +00:00 (Migrated from github.com)
Review

Would be fine with me, i just thought this would more obviously hint towards other options besides INFO.

Should i change it?

Would be fine with me, i just thought this would more obviously hint towards other options besides INFO. Should i change it?
modmuss50 commented 2021-09-21 12:00:57 +00:00 (Migrated from github.com)
Review

I would, I generally dont pass the level like that in a case like this.

I would, I generally dont pass the level like that in a case like this.
modmuss50 commented 2021-09-21 12:00:57 +00:00 (Migrated from github.com)
Review

I would, I generally dont pass the level like that in a case like this.

I would, I generally dont pass the level like that in a case like this.
StoneLabs commented 2021-09-21 12:02:05 +00:00 (Migrated from github.com)
Review

Alright, give me a minute.

Alright, give me a minute.
StoneLabs commented 2021-09-21 12:02:05 +00:00 (Migrated from github.com)
Review

Alright, give me a minute.

Alright, give me a minute.
Technici4n commented 2021-09-21 12:36:52 +00:00 (Migrated from github.com)
Review

Might want to give the logger a name, for example LogManager.getLogger("ExampleMod").

Might want to give the logger a name, for example `LogManager.getLogger("ExampleMod")`.
Technici4n commented 2021-09-21 12:36:52 +00:00 (Migrated from github.com)
Review

Might want to give the logger a name, for example LogManager.getLogger("ExampleMod").

Might want to give the logger a name, for example `LogManager.getLogger("ExampleMod")`.
StoneLabs commented 2021-09-21 12:45:09 +00:00 (Migrated from github.com)
Review

By default, the getLogger will use the Caller's class name. So that would be ExampleMod anyways.

// Returns a Logger with the name of the calling class.
// Returns:
//     The Logger for the calling class.
// Throws:
//     UnsupportedOperationException – if the calling class cannot be determined.
public static Logger getLogger() {
    return getLogger(StackLocatorUtil.getCallerClass(2));
}
By default, the getLogger will use the Caller's class name. So that would be ExampleMod anyways. ```java // Returns a Logger with the name of the calling class. // Returns: // The Logger for the calling class. // Throws: // UnsupportedOperationException – if the calling class cannot be determined. public static Logger getLogger() { return getLogger(StackLocatorUtil.getCallerClass(2)); } ```
StoneLabs commented 2021-09-21 12:45:09 +00:00 (Migrated from github.com)
Review

By default, the getLogger will use the Caller's class name. So that would be ExampleMod anyways.

// Returns a Logger with the name of the calling class.
// Returns:
//     The Logger for the calling class.
// Throws:
//     UnsupportedOperationException – if the calling class cannot be determined.
public static Logger getLogger() {
    return getLogger(StackLocatorUtil.getCallerClass(2));
}
By default, the getLogger will use the Caller's class name. So that would be ExampleMod anyways. ```java // Returns a Logger with the name of the calling class. // Returns: // The Logger for the calling class. // Throws: // UnsupportedOperationException – if the calling class cannot be determined. public static Logger getLogger() { return getLogger(StackLocatorUtil.getCallerClass(2)); } ```
liach commented 2021-09-21 14:29:07 +00:00 (Migrated from github.com)
Review

Imo we should use the mod id for the logger name.

Imo we should use the mod id for the logger name.
liach commented 2021-09-21 14:29:07 +00:00 (Migrated from github.com)
Review

Imo we should use the mod id for the logger name.

Imo we should use the mod id for the logger name.
sfPlayer1 commented 2021-09-21 19:35:29 +00:00 (Migrated from github.com)
Review

Yes, definitely mod id. It is the most useful for the end user and we want to promote best practices.

Yes, definitely mod id. It is the most useful for the end user and we want to promote best practices.
sfPlayer1 commented 2021-09-21 19:35:29 +00:00 (Migrated from github.com)
Review

Yes, definitely mod id. It is the most useful for the end user and we want to promote best practices.

Yes, definitely mod id. It is the most useful for the end user and we want to promote best practices.
StoneLabs commented 2021-09-21 21:33:16 +00:00 (Migrated from github.com)
Review

@sfPlayer1 How would I get the mod id? Or do you mean LogManager.getLogger("modid")?

@sfPlayer1 How would I get the mod id? Or do you mean `LogManager.getLogger("modid")`?
StoneLabs commented 2021-09-21 21:33:16 +00:00 (Migrated from github.com)
Review

@sfPlayer1 How would I get the mod id? Or do you mean LogManager.getLogger("modid")?

@sfPlayer1 How would I get the mod id? Or do you mean `LogManager.getLogger("modid")`?
sfPlayer1 commented 2021-09-21 21:38:17 +00:00 (Migrated from github.com)
Review

Yes, but please add a comment to encourage using the actual mod id. I may add something to Loader to determine it from a class eventually, but for now it's not really supported.

Yes, but please add a comment to encourage using the actual mod id. I may add something to Loader to determine it from a class eventually, but for now it's not really supported.
sfPlayer1 commented 2021-09-21 21:38:17 +00:00 (Migrated from github.com)
Review

Yes, but please add a comment to encourage using the actual mod id. I may add something to Loader to determine it from a class eventually, but for now it's not really supported.

Yes, but please add a comment to encourage using the actual mod id. I may add something to Loader to determine it from a class eventually, but for now it's not really supported.
StoneLabs commented 2021-09-21 21:47:40 +00:00 (Migrated from github.com)
Review

How does this sound?

// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LogManager.getLogger("modid");
How does this sound? ```java // This logger is used to write text to the console and the log file. // It is considered best practice to use your mod id as the logger's name. // That way, it's clear which mod wrote info, warnings, and errors. public static final Logger LOGGER = LogManager.getLogger("modid"); ```
StoneLabs commented 2021-09-21 21:47:40 +00:00 (Migrated from github.com)
Review

How does this sound?

// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LogManager.getLogger("modid");
How does this sound? ```java // This logger is used to write text to the console and the log file. // It is considered best practice to use your mod id as the logger's name. // That way, it's clear which mod wrote info, warnings, and errors. public static final Logger LOGGER = LogManager.getLogger("modid"); ```

View File

@ -12,6 +12,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class ExampleMixin {
@Inject(at = @At("HEAD"), method = "init()V")
private void init(CallbackInfo info) {
ExampleMod.LOGGER.log(Level.INFO, "This line is printed by an example mod mixin!");
ExampleMod.LOGGER.info("This line is printed by an example mod mixin!");
}
}