File tree 1 file changed +37
-2
lines changed
1 file changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -83,8 +83,8 @@ dc.logger = (function () {
83
83
} ;
84
84
85
85
/**
86
- * Use it to deprecate a function. It will return a wrapped version of the function, which will
87
- * will issue a warning when invoked. For each function, warning will be issued only once.
86
+ * Used to deprecate a function. It will return a wrapped version of the function, which will
87
+ * will issue a warning when invoked. The warning will be issued only once.
88
88
*
89
89
* @method deprecate
90
90
* @memberof dc.logger
@@ -114,5 +114,40 @@ dc.logger = (function () {
114
114
return deprecated ;
115
115
} ;
116
116
117
+ /**
118
+ * Used to provide an informational message for a function. It will return a wrapped version of
119
+ * the function, which will will issue a messsage with stack when invoked. The message will be
120
+ * issued only once.
121
+ *
122
+ * @method annotate
123
+ * @memberof dc.logger
124
+ * @instance
125
+ * @example
126
+ * _chart.interpolate = dc.logger.annotate(function (interpolate) {
127
+ * if (!arguments.length) {
128
+ * return _interpolate;
129
+ * }
130
+ * _interpolate = interpolate;
131
+ * return _chart;
132
+ * }, 'dc.lineChart.interpolate has been annotated since version 3.0 use dc.lineChart.curve instead');
133
+ * @param {Function } [fn]
134
+ * @param {String } [msg]
135
+ * @returns {Function }
136
+ */
137
+ _logger . annotate = function ( fn , msg ) {
138
+ // Allow logging of deprecation
139
+ var warned = false ;
140
+ function annotated ( ) {
141
+ if ( ! warned ) {
142
+ console . groupCollapsed ( msg ) ;
143
+ console . trace ( ) ;
144
+ console . groupEnd ( ) ;
145
+ warned = true ;
146
+ }
147
+ return fn . apply ( this , arguments ) ;
148
+ }
149
+ return annotated ;
150
+ } ;
151
+
117
152
return _logger ;
118
153
} ) ( ) ;
You can’t perform that action at this time.
0 commit comments