I am trying to log information within my system.Whenever logging I do a check if a state is valid and only then do I log that information.
//doing this logging all over the place in my code base. 
if(checkIsValid){
  Object obj =new Object(string1,Integer2,........String10);
  log(obj);
}
The question here is how do I refactor my code so that I don't have to repeat this block of code everywhere for logging.
One of the solution is I could write a supplementary method like this.
 method(String1,Integer2,......String10){
  if(checkIsValid){
  Object obj =new Object(string1,Integer2,.........String10);
  log(obj);
  }
}
But the downside is that I would have to pass a number of strings as arguments to my method which does not look clean at all.