author | Eugene Ostroukhov <eugeneo@symbian.org> |
Tue, 16 Mar 2010 18:01:11 -0700 | |
changeset 273 | b1f63c2c240c |
parent 211 | 7b148352159e |
permissions | -rw-r--r-- |
210
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
1 |
/** |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
2 |
* Copyright (c) 2009-2010 Symbian Foundation and/or its subsidiary(-ies). |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
3 |
* All rights reserved. |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
8 |
* |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
9 |
* Initial Contributors: |
273
b1f63c2c240c
Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
211
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
b1f63c2c240c
Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
211
diff
changeset
|
11 |
* |
210
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
12 |
* Contributors: |
273
b1f63c2c240c
Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
211
diff
changeset
|
13 |
* |
b1f63c2c240c
Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
211
diff
changeset
|
14 |
* Description: |
b1f63c2c240c
Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
211
diff
changeset
|
15 |
* |
210
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
102
diff
changeset
|
16 |
*/ |
73 | 17 |
|
18 |
/////////////////////////////////////////////////////////////////////////////// |
|
19 |
// Logger utility class that uses the Firebug console class. |
|
20 |
||
21 |
// Constructor (everything is static so this is empty). |
|
22 |
function Logger() { |
|
23 |
// Set default logger level. |
|
24 |
this.level = this.LOG_LEVEL_OFF; |
|
25 |
} |
|
26 |
||
27 |
// Logger levels. |
|
28 |
Logger.prototype.LOG_LEVEL_DEBUG = 0; |
|
29 |
Logger.prototype.LOG_LEVEL_INFO = 1; |
|
30 |
Logger.prototype.LOG_LEVEL_WARN = 2; |
|
31 |
Logger.prototype.LOG_LEVEL_ERROR = 3; |
|
32 |
Logger.prototype.LOG_LEVEL_OFF = 4; |
|
33 |
||
34 |
Logger.prototype.level = null; |
|
35 |
Logger.prototype.filter = null; |
|
36 |
||
37 |
// Disable logging on other browsers except Firefox. |
|
38 |
Logger.prototype.enabled = (navigator.userAgent.indexOf("Firefox") != -1); |
|
39 |
||
40 |
// Dumps an objects properties and methods to the console. |
|
41 |
Logger.prototype.dump = function(obj) { |
|
42 |
if (this.enabled) { |
|
43 |
console.dir(obj); |
|
44 |
} |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
45 |
}; |
73 | 46 |
|
47 |
// Dumps a stracktrace to the console. |
|
48 |
Logger.prototype.trace = function() { |
|
49 |
if (this.enabled) { |
|
50 |
console.trace(); |
|
51 |
} |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
52 |
}; |
73 | 53 |
|
54 |
// Prints a debug message to the console. |
|
55 |
Logger.prototype.debug = function(str) { |
|
56 |
if (this.enabled && this.level <= this.LOG_LEVEL_DEBUG) { |
|
57 |
if (this.filter == null) { |
|
58 |
console.debug(str); |
|
59 |
} else { |
|
60 |
var show = false; |
|
61 |
for (i in this.filter) { |
|
62 |
if (str.indexOf(this.filter[i]) >= 0) { |
|
63 |
show = true; |
|
64 |
break; |
|
65 |
} |
|
66 |
} |
|
67 |
if (show) { |
|
68 |
console.debug(str); |
|
69 |
} |
|
70 |
} |
|
71 |
} |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
72 |
}; |
73 | 73 |
|
74 |
// Prints an info message to the console. |
|
75 |
Logger.prototype.info = function(str) { |
|
76 |
if (this.enabled && this.level <= this.LOG_LEVEL_INFO) { |
|
77 |
console.info(str); |
|
78 |
} |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
79 |
}; |
73 | 80 |
|
81 |
// Prints a warning message to the console. |
|
82 |
Logger.prototype.warn = function(str) { |
|
83 |
if (this.enabled && this.level <= this.LOG_LEVEL_WARN) { |
|
84 |
console.warn(str); |
|
85 |
} |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
86 |
}; |
73 | 87 |
|
88 |
// Prints an error message to the console. |
|
89 |
Logger.prototype.error = function(str) { |
|
90 |
if (this.enabled && this.level <= this.LOG_LEVEL_ERROR) { |
|
91 |
console.error(str); |
|
92 |
} |
|
102
30e0796f3ebb
Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
73
diff
changeset
|
93 |
}; |