Split some client code to separate file

Adapt log functions/macros to be similar to karuibar's.