* Build a log emitter function for level minLevel. I.e. this is the * creator of `log.info`, `log.error`, etc.
(minLevel)
| 1008 | * creator of `log.info`, `log.error`, etc. |
| 1009 | */ |
| 1010 | function mkLogEmitter(minLevel) { |
| 1011 | return function () { |
| 1012 | var log = this; |
| 1013 | var str = null; |
| 1014 | var rec = null; |
| 1015 | |
| 1016 | if (!this._emit) { |
| 1017 | /* |
| 1018 | * Show this invalid Bunyan usage warning *once*. |
| 1019 | * |
| 1020 | * See <https://github.com/trentm/node-bunyan/issues/100> for |
| 1021 | * an example of how this can happen. |
| 1022 | */ |
| 1023 | var dedupKey = 'unbound'; |
| 1024 | if (!_haveWarned[dedupKey]) { |
| 1025 | var caller = getCaller3Info(); |
| 1026 | _warn(format('bunyan usage error: %s:%s: attempt to log ' |
| 1027 | + 'with an unbound log method: `this` is: %s', |
| 1028 | caller.file, caller.line, util.inspect(this)), |
| 1029 | dedupKey); |
| 1030 | } |
| 1031 | return; |
| 1032 | } else if (arguments.length === 0) { // `log.<level>()` |
| 1033 | return (this._level <= minLevel); |
| 1034 | } |
| 1035 | |
| 1036 | var msgArgs = new Array(arguments.length); |
| 1037 | for (var i = 0; i < msgArgs.length; ++i) { |
| 1038 | msgArgs[i] = arguments[i]; |
| 1039 | } |
| 1040 | |
| 1041 | if (this._level <= minLevel) { |
| 1042 | rec = mkRecord(log, minLevel, msgArgs); |
| 1043 | str = this._emit(rec); |
| 1044 | } |
| 1045 | |
| 1046 | if (probes) { |
| 1047 | probes[minLevel].fire(mkProbeArgs, str, log, minLevel, msgArgs); |
| 1048 | } |
| 1049 | } |
| 1050 | } |
| 1051 | |
| 1052 | |
| 1053 | /** |
no test coverage detected