javascript snippet for logging