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 logging with levels. #51
Conversation
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.
For now, just make logging.go
a file within utils
, no need for a separate directory (package) yet (though once utils grows enough I will do that).
Logging should be optional, and previously, was represented as a boolean key in the YAML config file (as log
) as well as a field (Log
) in the Config
struct. I like your implementation of logging levels, but wondering if using ints to represent them over string args is less user-friendly.
Ah right. I forgot to add it to the config. I'll fix that. I am using ints to represent levels because that's the natural way to represent levels. I used a "enum" to avoid accidentally inputting invalid logging levels (although Go doesn't support real enums so it's not completely safe anyways). Should we use strings like "one", "two", "three"? I also restricted it to 3 levels, which we could change or just remove any restriction on it. As for putting it in its own dir/package is because I wanted it to have its own package. Not just be
Even |
For logging, I was thinking of doing something similar to what I did for Postgres/MySQL detection in In terms of rearranging utils, I agree 100%, just want to minimize overhead as much as possible but that shouldn't be an issue anyway. Also, for the |
Logging now uses uint32 for log level. Logging options added to config file. Re-organized files and code because otherwise it caused cyclic dependency when using the Config type for the `Convert` (now `copyTable`) function. DB opening moved out from `Convert` function. CopyToX functions no longer in the same files as Config.
Ended up having to do some re-organizing to use the I changed logging to just use |
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.
I will merge once this is integrated with pipelining. I will have to examine this more deeply pre-merge. Also for logging levels, it's best to use uint8
because we don't need a higher range than that.
utils/config.go
Outdated
LogLevel *uint8 `yaml:"log_level"` | ||
LogFilename *string `yaml:"log_filename"` |
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.
Is there a reason why these field types have to be pointers?
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.
Looks good overall, please change the docs in README.md
to reflect config changes. Also, I think we should figure out an algorithm to generate the optimal chunk size based on row count but that can be done later.
Accidentally used `fmt.Print` instead of `log.Print`. fmt won't use the logfile if that is set.
Cool. Going to do some more testing on my end then will merge. Thanks |
Issue #50: reimplement logging.
I didn't write any logging in the copying part since that will be affected by the Redis Pipeline change.
I set it to 3 output levels because I thought that seemed reasonable. Another option could be to have different categories, like
Reads
,Writes
,Actions
, etc.