├── .gitignore ├── .npmignore ├── Gruntfile.coffee ├── LICENSE.md ├── README.md ├── binding.gyp ├── package-lock.json ├── package.json ├── spec └── nslog-spec.coffee └── src ├── main.cc ├── nslog.coffee ├── nslog.h ├── nslog_linux.cc ├── nslog_mac.mm └── nslog_win.cc /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /build 3 | /lib 4 | *.log 5 | *~ 6 | .node-version 7 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /build 2 | /spec 3 | *.coffee 4 | *.log 5 | *~ 6 | .node-version 7 | .npmignore 8 | -------------------------------------------------------------------------------- /Gruntfile.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (grunt) -> 2 | grunt.initConfig 3 | pkg: grunt.file.readJSON('package.json') 4 | 5 | coffee: 6 | glob_to_multiple: 7 | expand: true 8 | cwd: 'src' 9 | src: ['*.coffee'] 10 | dest: 'lib' 11 | ext: '.js' 12 | 13 | shell: 14 | rebuild: 15 | command: 'npm build .' 16 | options: 17 | stdout: true 18 | stderr: true 19 | failOnError: true 20 | 21 | clean: 22 | command: 'rm -fr build lib' 23 | options: 24 | stdout: true 25 | stderr: true 26 | failOnError: true 27 | 28 | 29 | test: 30 | command: 'npm test' 31 | options: 32 | stdout: true 33 | stderr: true 34 | failOnError: true 35 | 36 | grunt.loadNpmTasks('grunt-contrib-coffee') 37 | grunt.loadNpmTasks('grunt-shell') 38 | grunt.registerTask('default', ['coffee', 'shell:rebuild']) 39 | grunt.registerTask('test', ['default', 'shell:test']) 40 | grunt.registerTask('clean', ['shell:clean']) 41 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 GitHub Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ##### Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our [official announcement](https://github.blog/2022-06-08-sunsetting-atom/) 2 | # NSLog - Now you can log to console.app 3 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | 'target_defaults': { 3 | 'conditions': [ 4 | ['OS=="win"', { 5 | 'msvs_disabled_warnings': [ 6 | 4530, # C++ exception handler used, but unwind semantics are not enabled 7 | 4506, # no definition for inline function 8 | ], 9 | }], 10 | ], 11 | }, 12 | 'targets': [ 13 | { 14 | 'target_name': 'nslog', 15 | 'include_dirs': [ '=1.0.1", 316 | "gaze": "~0.3.2", 317 | "jasmine-reporters": ">=0.2.0", 318 | "requirejs": ">=0.27.1", 319 | "underscore": ">= 1.3.1", 320 | "walkdir": ">= 0.0.1" 321 | } 322 | }, 323 | "jasmine-reporters": { 324 | "version": "2.3.2", 325 | "resolved": "https://registry.npmjs.org/jasmine-reporters/-/jasmine-reporters-2.3.2.tgz", 326 | "integrity": "sha512-u/7AT9SkuZsUfFBLLzbErohTGNsEUCKaQbsVYnLFW1gEuL2DzmBL4n8v90uZsqIqlWvWUgian8J6yOt5Fyk/+A==", 327 | "dev": true, 328 | "requires": { 329 | "mkdirp": "^0.5.1", 330 | "xmldom": "^0.1.22" 331 | } 332 | }, 333 | "js-yaml": { 334 | "version": "2.0.5", 335 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-2.0.5.tgz", 336 | "integrity": "sha1-olrmUJmZ6X3yeMZxnaEb0Gh3Q6g=", 337 | "dev": true, 338 | "requires": { 339 | "argparse": "~ 0.1.11", 340 | "esprima": "~ 1.0.2" 341 | } 342 | }, 343 | "lodash": { 344 | "version": "0.9.2", 345 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-0.9.2.tgz", 346 | "integrity": "sha1-jzSZxSRdNG1oLlsNO0B2fgnxqSw=", 347 | "dev": true 348 | }, 349 | "lru-cache": { 350 | "version": "2.7.3", 351 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", 352 | "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", 353 | "dev": true 354 | }, 355 | "minimatch": { 356 | "version": "0.2.14", 357 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", 358 | "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", 359 | "dev": true, 360 | "requires": { 361 | "lru-cache": "2", 362 | "sigmund": "~1.0.0" 363 | } 364 | }, 365 | "minimist": { 366 | "version": "0.0.8", 367 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 368 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", 369 | "dev": true 370 | }, 371 | "mkdirp": { 372 | "version": "0.5.1", 373 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 374 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", 375 | "dev": true, 376 | "requires": { 377 | "minimist": "0.0.8" 378 | } 379 | }, 380 | "nan": { 381 | "version": "2.14.0", 382 | "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", 383 | "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" 384 | }, 385 | "nopt": { 386 | "version": "1.0.10", 387 | "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", 388 | "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", 389 | "dev": true, 390 | "requires": { 391 | "abbrev": "1" 392 | } 393 | }, 394 | "requirejs": { 395 | "version": "2.3.6", 396 | "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", 397 | "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", 398 | "dev": true 399 | }, 400 | "resolve": { 401 | "version": "0.3.1", 402 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-0.3.1.tgz", 403 | "integrity": "sha1-NMY0R8ZkxwWY0cmxJvxDsqJDEKQ=", 404 | "dev": true 405 | }, 406 | "rimraf": { 407 | "version": "2.2.8", 408 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", 409 | "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=", 410 | "dev": true 411 | }, 412 | "sigmund": { 413 | "version": "1.0.1", 414 | "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", 415 | "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", 416 | "dev": true 417 | }, 418 | "underscore": { 419 | "version": "1.7.0", 420 | "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", 421 | "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=", 422 | "dev": true 423 | }, 424 | "underscore.string": { 425 | "version": "2.2.1", 426 | "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.2.1.tgz", 427 | "integrity": "sha1-18D6KvXVoaZ/QlPa7pgTLnM/Dxk=", 428 | "dev": true 429 | }, 430 | "walkdir": { 431 | "version": "0.4.0", 432 | "resolved": "https://registry.npmjs.org/walkdir/-/walkdir-0.4.0.tgz", 433 | "integrity": "sha512-Ps0LSr9doEPbF4kEQi6sk5RgzIGLz9+OroGj1y2osIVnufjNQWSLEGIbZwW5V+j/jK8lCj/+8HSWs+6Q/rnViA==", 434 | "dev": true 435 | }, 436 | "which": { 437 | "version": "1.0.9", 438 | "resolved": "https://registry.npmjs.org/which/-/which-1.0.9.tgz", 439 | "integrity": "sha1-RgwdoPgQED0DIam2M6+eV15kSG8=", 440 | "dev": true 441 | }, 442 | "xmldom": { 443 | "version": "0.1.27", 444 | "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.27.tgz", 445 | "integrity": "sha1-1QH5ezvbQDr4757MIFcxh6rawOk=", 446 | "dev": true 447 | } 448 | } 449 | } 450 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "./lib/nslog.js", 3 | "name": "nslog", 4 | "description": "Cross platform native logging", 5 | "version": "3.2.0", 6 | "licenses": [ 7 | { 8 | "type": "MIT", 9 | "url": "http://github.com/atom/node-nslog/raw/master/LICENSE.md" 10 | } 11 | ], 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/atom/node-nslog.git" 15 | }, 16 | "bugs": { 17 | "url": "https://github.com/atom/node-nslog/issues" 18 | }, 19 | "scripts": { 20 | "prepublish": "grunt coffee", 21 | "test": "jasmine-node --captureExceptions --coffee spec/" 22 | }, 23 | "devDependencies": { 24 | "jasmine-node": "~1.5.0", 25 | "grunt": "~0.4.1", 26 | "grunt-contrib-coffee": "~0.6.6", 27 | "grunt-cli": "~0.1.7", 28 | "grunt-shell": "~0.2.2", 29 | "coffee-script": "~1.6.2" 30 | }, 31 | "dependencies": { 32 | "nan": "^2.14.0" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spec/nslog-spec.coffee: -------------------------------------------------------------------------------- 1 | NSLog = require '../lib/nslog' 2 | 3 | describe "nslog", -> 4 | it "logs", -> 5 | NSLog("holy cow") 6 | -------------------------------------------------------------------------------- /src/main.cc: -------------------------------------------------------------------------------- 1 | #include "nslog.h" 2 | 3 | #include "nan.h" 4 | using namespace v8; 5 | 6 | namespace { 7 | 8 | NAN_METHOD(Log) { 9 | Nan::HandleScope scope; 10 | 11 | Nan::Utf8String utf8_string(Local::Cast(info[0])); 12 | nslog::Log(*utf8_string); 13 | 14 | return; 15 | } 16 | 17 | void Init(Local exports) { 18 | Nan::SetMethod(exports, "log", Log); 19 | } 20 | 21 | } // namespace 22 | 23 | NODE_MODULE(nslog, Init) 24 | -------------------------------------------------------------------------------- /src/nslog.coffee: -------------------------------------------------------------------------------- 1 | NSLog = require('../build/Release/nslog.node') 2 | util = require('util') 3 | 4 | module.exports = (args...) -> 5 | NSLog.log(util.format(args...)) 6 | -------------------------------------------------------------------------------- /src/nslog.h: -------------------------------------------------------------------------------- 1 | #ifndef SRC_NSLOG_H_ 2 | #define SRC_NSLOG_H_ 3 | 4 | #include 5 | 6 | namespace nslog { 7 | 8 | void Log(const std::string& message); 9 | 10 | } // namespace nslog 11 | 12 | #endif // SRC_NSLOG_H_ 13 | -------------------------------------------------------------------------------- /src/nslog_linux.cc: -------------------------------------------------------------------------------- 1 | #include "nslog.h" 2 | 3 | #include 4 | 5 | namespace nslog { 6 | 7 | void Log(const std::string& message) { 8 | std::cout << message << std::endl; 9 | } 10 | 11 | } // namespace nslog 12 | -------------------------------------------------------------------------------- /src/nslog_mac.mm: -------------------------------------------------------------------------------- 1 | #include "nslog.h" 2 | 3 | #import 4 | 5 | namespace nslog { 6 | 7 | void Log(const std::string& message) { 8 | NSLog(@"%s", message.c_str()); 9 | } 10 | 11 | } // namespace nslog 12 | -------------------------------------------------------------------------------- /src/nslog_win.cc: -------------------------------------------------------------------------------- 1 | #include "nslog.h" 2 | 3 | #include 4 | 5 | namespace nslog { 6 | 7 | void Log(const std::string& message) { 8 | std::cout << message << std::endl; 9 | } 10 | 11 | } // namespace nslog 12 | --------------------------------------------------------------------------------