Extract warning logging into a dedicated function

Should work in browser, Node, and Web Worker environments.