Basic logging, environment and error management functionality for javascript client/server applications.
Features
breadcrumbs to help with errors:
add() tracking them propagating through your callbacks
newError() ensuring callstacks on the client
toString() preparing them for logs
Client-only:
Basic winston and util shims for use with requirejs
Server-only:
logs.setupFile()/setupConsole() for quick winston setup on the server (if winston is installed - if not, these methods do nothing. Tested with winston@0.7.x and winston@0.8.x)
env.merge() method to merge data from '<CWD>/env.js' (or '<CWD>/env.json', or a path you specify) with values already on process.env
Supported browsers
Sadly, IE9 and Safari5 are both unwilling to give us callstacks. We won't crash, but you'll get empty strings for stacks and breadcrumbs like this: '**breadcrumb: <empty>'. Android 4.0 has two extra keys printed out from exceptions: arguments and type.
(please pardon the sauce labs bug - errors in these downlevel browsers aren't resulting in highlights for the right versions...)
Setup
First install the project as a dependency:
npm install thehelp-core --save
Usage
On the server, just require it and start using it!
var core = require('thehelp-core');
core.env.merge();
core.logs.setupConsole();
core.logs.setupFile('./logs/server.log');
On the client side, you'll just need to tell requirejs a few things:
requirejs.config({
baseUrl: '/',
paths: {
'thehelp-core': 'node_modules/thehelp-core/dist/thehelp-core',
// you can use the provided shims like this:
util: 'node_modules/thehelp-core/dist/shims/util_shim',
winston: 'node_modules/thehelp-core/dist/shims/winston_shim'
}
})
Then you can use thehelp-core in your client code (or code that works client/server):
The client-side dev and dist tests under 'test/integration' will be your friend. :0) They'll help you ensure that the client-side part of this library is working properly. Use grunt connect:keepalive to test it in your browser.
Please cover as many browsers as you can, or use grunt cross-browser with your Sauce Credentials in env.json. When you have some changes ready, please submit a pull request with:
Justification - why is this change worthwhile? Link to issues, use code samples, etc.
Documentation changes for your code updates. Be sure to check the groc-generated HTML with grunt doc
A description of how you tested the change. Don't forget about the very-useful npm link command :0)
I may ask you to use a git rebase to ensure that your commits are not interleaved with commits already in the history. And of course, make sure grunt completes successfully (take a look at the requirements for thehelp-project). :0)
License
(The MIT License)
Copyright (c) 2013 Scott Nonnenberg <scott@nonnenberg.com>
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.
thehelp-core
Basic logging, environment and error management functionality for javascript client/server applications.
Features
breadcrumbs
to help with errors:add()
tracking them propagating through your callbacksnewError()
ensuring callstacks on the clienttoString()
preparing them for logsClient-only:
winston
andutil
shims for use withrequirejs
Server-only:
logs.setupFile()/setupConsole()
for quickwinston
setup on the server (ifwinston
is installed - if not, these methods do nothing. Tested withwinston@0.7.x
andwinston@0.8.x
)env.merge()
method to merge data from '<CWD>/env.js' (or '<CWD>/env.json', or a path you specify) with values already onprocess.env
Supported browsers
Sadly, IE9 and Safari5 are both unwilling to give us callstacks. We won't crash, but you'll get empty strings for stacks and breadcrumbs like this: '**breadcrumb: <empty>'. Android 4.0 has two extra keys printed out from exceptions:
arguments
andtype
.(please pardon the sauce labs bug - errors in these downlevel browsers aren't resulting in highlights for the right versions...)
Setup
First install the project as a dependency:
Usage
On the server, just require it and start using it!
On the client side, you'll just need to tell
requirejs
a few things:Then you can use
thehelp-core
in your client code (or code that works client/server):Detailed Documentation
Detailed docs be found at this project's GitHub Pages, thanks to
groc
: http://thehelp.github.io/coreContributing changes
The client-side
dev
anddist
tests under 'test/integration' will be your friend. :0) They'll help you ensure that the client-side part of this library is working properly. Usegrunt connect:keepalive
to test it in your browser.Please cover as many browsers as you can, or use
grunt cross-browser
with your Sauce Credentials in env.json. When you have some changes ready, please submit a pull request with:grunt doc
npm link
command :0)I may ask you to use a
git rebase
to ensure that your commits are not interleaved with commits already in the history. And of course, make suregrunt
completes successfully (take a look at the requirements forthehelp-project
). :0)License
(The MIT License)
Copyright (c) 2013 Scott Nonnenberg <scott@nonnenberg.com>
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.