-
Notifications
You must be signed in to change notification settings - Fork 92
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
Log objects directly. #6
base: master
Are you sure you want to change the base?
Conversation
Thanks for your contribution, @takawitter! I've checked the overview of your commits, and it seems to take a bit of time to review. Could you wait a moment? Thanks, Tsuyoshi |
@takawitter: I ran The log is as follows:
|
Thanks for your comment, oza. The exception you pointed seems to be designed to be thrown in test code.
Though the log message said fatal, but no test case failed. regards. |
Oops, I have a mistake about my local branch management. Thanks for your point, and please wait a moment. |
The confusing log message at testing is filed as #7. Thank you for reporting. The review comment is as follows: Thanks, Tsuyoshi |
Or, if we can design the feature more simply, I'd like to merge your pull request. Now I'm thinking more simple one. |
Thank you for the consideration. I investigated fluentd feature, it seems to be designed to accept JSON map (not JSON array or values).
My motivations as follows: regards. |
I apologize for the delay. The use case you pointed out looks good to me. Thank you for the sharing :-) The review comment against the implementation:
IIUC, events described in 1. is the same events the method public void write(Packer pk, Event v, boolean required) throws IOException {
if (v == null) {
if (required) {
throw new MessageTypeException("Attempted to write null");
}
pk.writeNil();
return;
}
pk.writeArrayBegin(3);
{
Templates.TString.write(pk, v.tag, required);
Templates.TLong.write(pk, v.timestamp, required);
if(v.data instanceof Map){
writeMap(pk, (Map<?, ?>)v.data, required);
} else{
pk.write(v.data); // We should throw exception if we don't know how to serialize it!
}
}
pk.writeArrayEnd();
} What do you think? |
writeObj method writes map value of POJO. System.out.println(mp.read(mp.write(new Msg("bob", 20)))); you will get the string: ["bob",20], not {"name":"bob","age":20}. regards. |
You're correct and I may confuse you because of my expression of the sentence. I apologize for this. What I'd like to say here is: the events described in 1. is subset of This is summary of my thought: I agree that fluent-logger-java should accept POJOs themselves. However, when we would like to send them as public static class ParentMsg {
final private String strForTesting = "hoge";
public ParentMsg() {
}
public String getStrForTesting() {
return strForTesting;
}
}
public static class Msg extends ParentMsg {
public Msg() {
super();
}
public Msg(String name) {
this.name = name;
}
private String name;
} Your proposal sends "strForTesting" => "hoge" as a part of events when Msg objects are serialized. Is it really a part of events you'd like to send? One alternative to omit Map's key is that your proposal is done in msgpack-java layer, as an extension of annotation - |
Yes. Converting Java Object to map value is what I wanted to do. Not array value.
Did you mean extending msgpack-java to support map-style serialization such like @message(style=SerializationStyle.map) ? thanks. |
I implemented @message(style=SerializationStyle.MAP). What do you think of this kind of change? Anyway, I considered about alternative. By these change, users can simply choose object serialization style or customize serialization p.s. my motivation substantiate by a. and b. c. is for superior customizability. best regards. |
MapStyleEventTemplate.
I added the commit that realizes above a. and b. But not yet c. Because I best regards. |
I made patch to support logging Java objects and some primitives.
This patch enables users to log objects like these:
outputs:
I also leave log(String, Map<String, Object>) method available.
regards.