Created
September 26, 2013 00:38
-
-
Save blindman2k/6708281 to your computer and use it in GitHub Desktop.
Posting log entries to Loggly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const LOGGLY_URL = "https://logs-01.loggly.com/inputs/TOKEN/tag/imp/"; | |
function log(message, callback = null) { | |
if (typeof message != "object") { | |
message = {message = message}; | |
} | |
http.post(LOGGLY_URL, {}, http.jsonencode(message)).sendasync(function (res) { | |
if (res.statuscode != 200) server.log("Error posting to Logly: " + res.statuscode); | |
if (callback) callback(res); | |
}) | |
} | |
log("Hello, world!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment