Code:
on 1:INPUT:#: { 
  if ($1 != .timeout) && ($1 != .ban) && ($1 != .unban) return 
  if ($1 == .ban) { var %Command = Ban, %Text = was permanently banned for }
  elseif ($1 == .timeout) { var %Command = Timeout, %Text = was timed out for, %Text2 = seconds for }
  elseif ($1 == .unban) { var %Command = Unban, %Text = was pardoned and unbanned from $regsubex(#,^#*,) for }
  if (%Text2) { write # $+ log.txt ( $+ $regsubex(#,^#*,) $+ ) ( $+ %command $+ )  < $+ $time(yyyy-mm-dd) @ $time $+ > $2 %Text $3 %Text2 $4- | return }
  write # $+ log.txt ( $+ $regsubex(#,^#*,) $+ ) ( $+ %command $+ )  < $+ $time(yyyy-mm-dd) @ $time $+ > $2 %Text $3-
}
Tested with the exact results you asked for. (apart from that the Channel will not start with an uppercased letter, I'm not sure how to do that easily.)
This will save individual files for each channel. If you want to save them all to the same file, remove the "# $+" from both "# $+ log.txt"