Fail-safe Javascript logger with callback support