Repository: i-break-codes/ejs
Branch: master
Commit: d112dfd7a31b
Files: 6
Total size: 10.2 KB
Directory structure:
gitextract_qn3yl___/
├── .gitignore
├── LICENSE
├── README.md
├── bower.json
├── logerr.js
└── package.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.DS_Store
/node_modules
/resources
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2016 Vaibhav Mehta
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================

[](https://cdnjs.com/libraries/logerr)
Logerr or Log Error. Playing with console errors, experimental project. Started developing for Chrome but now it supports Internet Explorer as well as Edge.
#### Online Demo
[View](https://i-break-codes.github.io/logerr/) (Don't forget to open your dev console)
---
#### What does it do?
Provides JavaScript error details in a readable format. You can log these errors remotely by enabling `remoteLogging`. After enabling, logerr will send a post request to the desired action/url with exception details along with custom parameters (if provided using `additionalParams`).
---
#### Install:
#### CDN
**Development [Unminified]**
> https://cdnjs.cloudflare.com/ajax/libs/logerr/1.2.0/logerr.js
**Production [Minified]**
> https://cdnjs.cloudflare.com/ajax/libs/logerr/1.2.0/logerr.min.js
#### [npm](http://npmjs.com)
```bash
npm install i-break-codes/logerr
```
#### [Bower](https://bower.io/)
```bash
bower install logerr
```
#### Manually
Download `logerr.js` and follow the setup instructions below.
---
#### Setup
Just include `logerr.js` file and the `init()` i.e initializer in the `<head>` section of your page, before you include any other JavaScript. `init()` will initialize the lib, where later you can pass an object to customize.
```html
<!DOCTYPE html>
<html lang="en">
<head>
<script src="logerr.js"></script>
<script>
Logerr.init();
</script>
</head>
<body>
Am fancy
</body>
</html>
```
---
#### Enable remote logging
> Make sure you have CORS enabled if logging cross-domain.
```javascript
//Request type is POST
Logerr.init({
remoteLogging: true, //Checkout https://github.com/i-break-codes/logerr-remote
remoteSettings: {
url: 'REMOTE_URL',
additionalParams: {
logged_by: 'Sam'
},
successCallback: function () {
console.log('Im logged.');
},
errorCallback: function () {
console.log('Err! Something went wrong.');
}
}
});
```
Also checkout Logerr Remote to log these exceptions remotely. (Powered by NodeJS)
[View](https://github.com/i-break-codes/logerr-remote)
---
#### Default Configuration & Datatypes
```javascript
detailedErrors: true //Boolean true/false, optional
remoteLogging: false //Boolean true/false, optional
remoteSettings: { //Object {}, required if remoteLogging is set to true
url: null, //String '', required if remoteLogging is set to true
additionalParams: null, //Object {}, optional
successCallback: null, //function() {}, optional
errorCallback: null //function() {}, optional
}
```
---
#### Roadmap
- [x] Enable/Disable detailedErrors mode in console.
- [x] Remote logging by sending post request
- [x] Cross browser support (Partially fixed)
- [ ] Add notifications on the page if any exception. (in progress)
...will add some more stuff to make debugging easy.
---
#### Support
- Bugs and requests, submit them through the project's issues section
- Questions? DM or Tweet me [@mr_ali3n](https://twitter.com/mr_ali3n)
Thanks to all contributors, stargazers, pr's, issue submissions for suggesting features and making this more awesome.
================================================
FILE: bower.json
================================================
{
"name": "logerr",
"main": "logger.js",
"homepage": "https://github.com/i-break-codes/logerr",
"authors": [
"i-break-codes <vaibhav@browserstack.com>"
],
"description": "Provides JavaScript errors in readable format. Also allows developers to log exceptions remotely by sending a post reqest.",
"keywords": [
"javascript",
"debug",
"errorhandling",
"log",
"errorlogging",
"remotelogging",
"exceptionhandling",
"exceptions"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
================================================
FILE: logerr.js
================================================
/**
* logerr
*
* @category logerr
* @author Vaibhav Mehta <firekillz@gmail.com>
* @copyright Copyright (c) 2016 Vaibhav Mehta <https://github.com/i-break-codes>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 1.2 Stable
*/
var Logerr = function() {
'use strict';
var setConfig;
function init(userConfig) {
if(!userConfig) userConfig = {};
// Default configuration
var config = {
detailedErrors: true,
remoteLogging: false,
remoteSettings: {
url: null,
additionalParams: null,
successCallback: null,
errorCallback: null
}
};
// Override with user config
setConfig = Object.assign(config, userConfig);
//Remove current listener
window.removeEventListener('error', _listener);
// Listen to errors
window.addEventListener('error', _listener);
}
// NOTE: Private
function _listener(e) {
if(setConfig.detailedErrors) {
_detailedErrors(e);
}
if(setConfig.remoteLogging) {
_remoteLogging(e, setConfig.remoteSettings);
}
}
function _detailedErrors(e) {
var i = _errorData(e);
var helpPath = encodeURI("https://stackoverflow.com/search?q=" + i.error.split(' ').join('+'));
var str = [
"%cType: %c" + i.type,
"%cError: %c" + i.error,
"%cStackTrace: %c" + i.stackTrace,
"%cFile Name: %c" + i.filename,
"%cPath: %c" + i.path,
"%cLine: %c" + i.line,
"%cColumn: %c" + i.column,
"%cDate: %c" + i.datetime,
"%cDebug : %c" + i.path + ':' + i.line,
"%cGet Help: " + "%c" + helpPath
].join("\n");
if(window.chrome) {
console.log(str, "font-weight: bold;", "color: #e74c3c;", "font-weight: bold;", "font-weight: normal; color: #e74c3c;","font-weight: bold;", "font-weight: normal; color: #e74c3c;", "font-weight: bold;", "font-weight: normal;", "font-weight: bold;", "font-weight: normal;", "font-weight: bold;", "font-weight: normal;", "font-weight: bold;", "font-weight: normal;", "font-weight: bold;", "font-weight: normal;", "font-weight: bold;", "font-weight: normal;", "font-weight: bold;", "font-weight: normal; color: #3498db;");
} else {
console.log(str.replace(/%c/gi, ''));
}
}
function _remoteLogging(e, remoteSettings) {
if(!remoteSettings.url) {
throw new Error('Provide remote URL to log errors remotely');
} else if(remoteSettings.additionalParams && typeof remoteSettings.additionalParams !== 'object') {
throw new Error('Invalid data type, additionalParams should be a valid object');
}
var http = new XMLHttpRequest();
var url = remoteSettings.url;
var data = _errorData(e);
var setData = Object.assign(data, remoteSettings.additionalParams);
var params = _serializeData(setData);
http.open("POST", url, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.send(params);
http.onreadystatechange = function() {
if(http.readyState == 4 && http.status == 200) {
if (http.readyState == XMLHttpRequest.DONE) {
if(remoteSettings.successCallback) {
remoteSettings.successCallback();
}
} else {
if(remoteSettings.errorCallback) {
remoteSettings.errorCallback();
} else {
throw new Error('Remote error logging failed!');
}
}
}
};
}
function _serializeData(params) {
return Object.keys(params).map(function(k) {
return encodeURIComponent(k) + "=" + encodeURIComponent(params[k]);
}).join('&');
}
function _errorData(e) {
var filename = e.filename.lastIndexOf('/');
var datetime = new Date().toString();
/**
* userAgent only for POST request purposes, not required in pretty print
*/
return {
type: e.type,
path: e.filename,
filename: e.filename.substring(++filename),
line: e.lineno,
column: e.colno,
error: e.message,
stackTrace: ((e.error) ? e.error.stack.toString().replace(/(\r\n|\n|\r)/gm,"") : ""),
datetime: datetime,
userAgent: navigator.userAgent || window.navigator.userAgent
};
}
//Polyfill for Object.assign
if (typeof Object.assign != 'function') {
Object.assign = function(target) {
if (target === null) {
throw new TypeError('Cannot convert undefined or null to object');
}
target = Object(target);
for (var index = 1; index < arguments.length; index++) {
var source = arguments[index];
if (source !== null) {
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
}
return target;
};
}
return {
init: init
};
}();
================================================
FILE: package.json
================================================
{
"name": "logerr",
"version": "1.2.0",
"repository": "https://github.com/i-break-codes/logerr.git",
"main": "logerr.js",
"homepage": "https://github.com/i-break-codes/logerr",
"authors": [
"i-break-codes <vaibhav@browserstack.com>"
],
"description": "Provides JavaScript errors in readable format. Also allows developers to log exceptions remotely by sending a post reqest.",
"keywords": [
"javascript",
"debug",
"errorhandling",
"log",
"errorlogging",
"remotelogging",
"exceptionhandling",
"exceptions"
],
"license": "MIT"
}
gitextract_qn3yl___/ ├── .gitignore ├── LICENSE ├── README.md ├── bower.json ├── logerr.js └── package.json
SYMBOL INDEX (6 symbols across 1 files)
FILE: logerr.js
function init (line 16) | function init(userConfig) {
function _listener (line 42) | function _listener(e) {
function _detailedErrors (line 52) | function _detailedErrors(e) {
function _remoteLogging (line 76) | function _remoteLogging(e, remoteSettings) {
function _serializeData (line 110) | function _serializeData(params) {
function _errorData (line 116) | function _errorData(e) {
Condensed preview — 6 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (11K chars).
[
{
"path": ".gitignore",
"chars": 35,
"preview": ".DS_Store\n/node_modules\n/resources\n"
},
{
"path": "LICENSE",
"chars": 1080,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2016 Vaibhav Mehta\n\nPermission is hereby granted, free of charge, to any person obt"
},
{
"path": "README.md",
"chars": 3294,
"preview": "\n\n[](https://cdnjs.com/libr"
},
{
"path": "bower.json",
"chars": 600,
"preview": "{\n \"name\": \"logerr\",\n \"main\": \"logger.js\",\n \"homepage\": \"https://github.com/i-break-codes/logerr\",\n \"authors\": [\n "
},
{
"path": "logerr.js",
"chars": 4883,
"preview": "/**\n * logerr\n *\n * @category logerr\n * @author Vaibhav Mehta <firekillz@gmail.com>\n * @copyright Copyright (c) 2"
},
{
"path": "package.json",
"chars": 585,
"preview": "{\n \"name\": \"logerr\",\n \"version\": \"1.2.0\",\n \"repository\": \"https://github.com/i-break-codes/logerr.git\",\n \"main\": \"lo"
}
]
About this extraction
This page contains the full source code of the i-break-codes/ejs GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 6 files (10.2 KB), approximately 2.7k tokens, and a symbol index with 6 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.