api,app,log,provision: creating write function in log pkg

Also refactoring packages that defined it to use the one from log pkg.