]>
git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/core/log.js
2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
7 * @fileOverview Defines {@link CKEDITOR#verbosity} and binary flags {@link CKEDITOR#VERBOSITY_WARN} and
8 * {@link CKEDITOR#VERBOSITY_ERROR}. Defines also the {@link CKEDITOR#error} and {@link CKEDITOR#warn} functions
9 * and the default handler for the {@link CKEDITOR#log} event.
17 * Warning reporting verbosity level. When {@link CKEDITOR#verbosity} is set to this value, only {@link CKEDITOR#warn}
18 * messages will be output to the console. It is a binary flag so it might be combined with
19 * the {@link CKEDITOR#VERBOSITY_ERROR} flag.
23 * @property {Number} [=1]
26 CKEDITOR
.VERBOSITY_WARN
= 1;
29 * Error reporting verbosity level. When {@link CKEDITOR#verbosity} is set to this value, only {@link CKEDITOR#error}
30 * messages will be output to the console. It is a binary flag so it might be combined with
31 * the {@link CKEDITOR#VERBOSITY_WARN} flag.
35 * @property {Number} [=2]
38 CKEDITOR
.VERBOSITY_ERROR
= 2;
41 * Verbosity of {@link CKEDITOR#error} and {@link CKEDITOR#warn} methods. Accepts binary flags
42 * {@link CKEDITOR#VERBOSITY_WARN} and {@link CKEDITOR#VERBOSITY_ERROR}.
44 * CKEDITOR.verbosity = 0; // No console output after CKEDITOR.warn and CKEDITOR.error methods.
45 * CKEDITOR.verbosity = CKEDITOR.VERBOSITY_WARN; // Console output after CKEDITOR.warn only.
46 * CKEDITOR.verbosity = CKEDITOR.VERBOSITY_ERROR; // Console output after CKEDITOR.error only.
47 * CKEDITOR.verbosity = CKEDITOR.VERBOSITY_WARN | CKEDITOR.VERBOSITY_ERROR; // Console output after both methods.
49 * Default value enables both {@link CKEDITOR#VERBOSITY_WARN} and {@link CKEDITOR#VERBOSITY_ERROR}.
55 CKEDITOR
.verbosity
= CKEDITOR
.VERBOSITY_WARN
| CKEDITOR
.VERBOSITY_ERROR
;
58 * Warning reporting function. When {@link CKEDITOR#verbosity} has the {@link CKEDITOR#VERBOSITY_WARN} flag set, it fires
59 * the {@link CKEDITOR#log} event with type set to `warn`. Fired event contains also provided `errorCode` and `additionalData`.
63 * @param {String} errorCode Error code describing reported problem.
64 * @param {Object} [additionalData] Additional data associated with reported problem.
66 CKEDITOR
.warn = function( errorCode
, additionalData
) {
67 if ( CKEDITOR
.verbosity
& CKEDITOR
.VERBOSITY_WARN
) {
68 CKEDITOR
.fire( 'log', { type: 'warn', errorCode: errorCode
, additionalData: additionalData
} );
73 * Error reporting function. When {@link CKEDITOR#verbosity} has {@link CKEDITOR#VERBOSITY_ERROR} flag set, it fires
74 * {@link CKEDITOR#log} event with the type set to `error`. The fired event also contains the provided `errorCode` and
79 * @param {String} errorCode Error code describing the reported problem.
80 * @param {Object} [additionalData] Additional data associated with the reported problem.
82 CKEDITOR
.error = function( errorCode
, additionalData
) {
83 if ( CKEDITOR
.verbosity
& CKEDITOR
.VERBOSITY_ERROR
) {
84 CKEDITOR
.fire( 'log', { type: 'error', errorCode: errorCode
, additionalData: additionalData
} );
89 * Fired by {@link CKEDITOR#warn} and {@link CKEDITOR#error} methods.
90 * Default listener logs provided information to the console.
92 * This event can be used to provide a custom error/warning handler:
94 * CKEDTIOR.on( 'log', function( evt ) {
95 * // Cancel default listener.
98 * console.log( evt.data.type, evt.data.errorCode, evt.data.additionalData );
105 * @param {String} data.type Log type. Can be `error` or `warn`.
106 * @param {String} data.errorCode Error code describing the reported problem.
107 * @param {Object} [data.additionalData] Additional data associated with this log event.
109 CKEDITOR
.on( 'log', function( evt
) {
110 if ( !window
.console
|| !window
.console
.log
) {
114 var type
= console
[ evt
.data
.type
] ? evt
.data
.type : 'log',
115 errorCode
= evt
.data
.errorCode
,
116 additionalData
= evt
.data
.additionalData
,
117 prefix
= '[CKEDITOR] ',
118 errorCodeLabel
= 'Error code: ';
120 if ( additionalData
) {
121 console
[ type
]( prefix
+ errorCodeLabel
+ errorCode
+ '.', additionalData
);
123 console
[ type
]( prefix
+ errorCodeLabel
+ errorCode
+ '.' );
126 console
[ type
]( prefix
+ 'For more information about this error go to http://docs.ckeditor.com/#!/guide/dev_errors-section-' + errorCode
);
127 }, null, null, 999 );