-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relaxing Context type for better DX (#71)
- Loading branch information
Showing
7 changed files
with
44 additions
and
23 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,14 +19,14 @@ const logger = new Logtail(process.argv[2], { sendLogsToConsoleOutput: true }); | |
// Usage | ||
|
||
// Send debug level log using the debug() method | ||
logger.debug("I am using Logtail!"); | ||
const debugLog = logger.debug("I am using Logtail!"); | ||
|
||
// Send info level log using the info() method | ||
logger.info("An interesting event occured!") | ||
const infoLog = logger.info("An interesting event occured!"); | ||
|
||
// Send warn level log using the warn() method | ||
// You can add additional structured data to help you troubleshoot your code as shown below | ||
logger.warn("Something is not quite right, better check on it.",{ | ||
const warningLog = logger.warn("Something is not quite right, better check on it.",{ | ||
user:{ | ||
username:"someuser", | ||
email:"[email protected]" | ||
|
@@ -36,9 +36,20 @@ logger.warn("Something is not quite right, better check on it.",{ | |
} | ||
}); | ||
|
||
// Send error level log using the error() method | ||
logger.error("Oops! An runtime ERROR occurred!").then( | ||
// Logging methods are async function returning Promises | ||
function callbackThatMightFail() { | ||
throw new Error("Testing error") | ||
} | ||
|
||
let errorLog; | ||
try { | ||
callbackThatMightFail(); | ||
} catch (err) { | ||
// Send error level log using the error() method | ||
errorLog = logger.error("Oops! An runtime ERROR occurred!", err); | ||
} | ||
|
||
// Logging methods are async function returning Promises | ||
Promise.all([debugLog, infoLog, warningLog, errorLog]).then( | ||
// OnResolve write message | ||
function() { | ||
console.log("All done! You can check your logs now.") | ||
|
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
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
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
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
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
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