-
Notifications
You must be signed in to change notification settings - Fork 9
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
Added support for debug logging #14
base: typescript
Are you sure you want to change the base?
Conversation
Don't necessarily see the point of this - |
Why would that be impractical? That is how a lot of software works. Normal use case is either info or warning and then a debug for well debugging. You don't want to leave debug logging running all the time as (depending on the software ofc) this can cause for a lot of disk usage. The built-in console functions do not have anything to set a log level (as far as I know correct me if I'm wrong). For example: I have issues with leave messages so I want to know what the bot is doing. Is it reading correctly from factorio (and then not sending?) Or is it not parsing? Or can't it post to Discord. So I want stuff that logs it all but for the normal flow that only wastes disk space. Me not using |
There's a config toggle on whether or not to send debug messages to the console, see
In this case, you could use My concern is that this pull request adds a lot of unneeded bloat for a config feature that exists already or could simply be altered. |
It could be an idea to make every log be able to be set, but except for |
But that config item really logs everything, the nice thing about log levels is that the user can decide how much logging he/she wants. But I agree that you want one of them, not both. I don't mind using the other console functions, doesn't change anything in the output for cli afaik.
Well other stuff could be discord status checks, the parsing of messages for example. The more features you add the more stuff that (might) break. |
Hmm, interesting.. |
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.
Regardless of whether this becomes merged, there are changes that need to be made.
mod_updater.py | ||
|
||
.idea |
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.
Why was .idea
added?
|
||
import { Rcon } from "rcon-client"; | ||
import {Rcon} from "rcon-client"; |
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.
Convention is spaces between words and brackets.
@@ -16,6 +16,13 @@ const bot = new Discord.Client({ intents: [Intents.FLAGS.GUILD_MESSAGES, Intents | |||
|
|||
const Commands: Discord.Collection<string, Command> = new Discord.Collection(); | |||
|
|||
enum LOGLEVELS { |
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.
Convention is order numerically. Additionally, should increment by 1 unless there is a specific reason why 2 is chosen.
ERROR = 1,
INFO = 2,
DEBUG = 3
@@ -404,7 +416,7 @@ function readLastLine(path: fs.PathOrFileDescriptor) { | |||
|
|||
// I should really optimize or completely remove this line | |||
if (config.logLines) { | |||
console.log(lastLine); | |||
log(LOGLEVELS.DEBUG, `Got message from Factorio ${lastLine}`); |
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.
Colon after "Factorio"
Just a suggestion to make it a bit easier to debug stuff (leave messages still don't work all the time for me).