Client-side (browser) logger to use with Loggly gen2. Check out Loggly's [Javascript logging documentation](https://www.loggly.com/docs/javascript/) to learn more.
Client-side (browser) logger to use with Loggly gen2. Check out Loggly's [Javascript logging documentation](https://www.loggly.com/docs/javascript/) to learn more.
Installation
------------
Place the following on your page, and replace the logglyKey value with the key provided by the website:
@@ -48,7 +49,7 @@ myBetterLogger.push({'logglyKey': 'your-customer-token' }); // push a loggly ke
Send Console Errors to Loggly
----
Keeping <strong>sendConsoleErrors</strong> value to <i>true</i> will send all the unhandled errors to the Loggly with the detailed information like error message, URL, line number and column number. This script also take cares of all the previously defined window.onerror functions.
Keeping <strong>sendConsoleErrors</strong> value to <i>true</i> will send all the unhandled errors to the Loggly with the detailed information like error message, URL, line number and column number. This script also take cares of all the previously defined window.onerror functions.
Send Tags to Loggly
----
@@ -98,3 +99,81 @@ You can build min and map file by using the command below:
npm install
grunt
```
Intercept and log any JavaScript function calls
----------
You may not like the mixing the Loggly logging codes everywhere inside your application codes. This creates undesirable dependencies on the Loggly and makes your codes ugly.
Instead you may rather prefer transparently send messages passed into the console.log, console.warn, console.info and console.error to the Loggly. Or you may even not like the console.log() functions as well. You prefer to decide which part of the code you would like to log when some issues happens on live instead of making decisition at development time. So you would like to use the configuration to control the logging behaviour transparently from the applications.
Also you may like to enable this automatic logging for only some percentage of user sessions, instead of all users.
For example if you would to log the console.error() function, you just need to put the code below as soon as you have initialised the Loggly:
```Javascript
_LTracker.injectLog({
enable:100
target:"console.error",
name:"error"
});
```
The value of ```enable``` attribute is set 100. This means thar the Loggly will log the console.error() function for 100% percent of the users, which means all user sessions.
The value of the ```target``` attribute specifies which javascript function it needs to monitor. It has to have atleast one "." to specify the target object and target method the Loggly needs to monitor.
The functions that the Loggly intercept will not be affected. For example, console.error() will still continually print messages to the console as usual. The injected codes will simply send the messages to loggly after executing the original console function. For example, if the application executes the following code:
```Javascript
console.error("Something wrong");
```
Then the injected code will transparently executes the following code:
```Javascript
_LTracker.push({
error:"Something wrong"
});
```
The name of the variable ```error``` is coming from the ```name``` attribute passed into the ```_LTracker.injectLog``` in the previous example.
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
Learn more.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
You can always update your selection by clicking Cookie Preferences at the bottom of the page.
For more information, see our Privacy Statement.
Essential cookies
We use essential cookies to perform essential website functions, e.g. they're used to log you in.
Learn more
Always active
Analytics cookies
We use analytics cookies to understand how you use our websites so we can make them better, e.g. they're used to gather information about the pages you visit and how many clicks you need to accomplish a task.
Learn more
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
injecting log to any javascript function #51
base: master
injecting log to any javascript function #51
Changes from 1 commit
6be4ea9e1acf4432c09787bcf0f56dd1a8447ac792c0d316fd656fe072a141477573a7File filter...
Jump to…
modified readme to include the code injection