Siobhan Tully | e18b344 | 2014-02-23 14:23:34 -0500 | [diff] [blame] | 1 | <?xml version="1.0"?>
|
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
| 4 | <head>
|
| 5 | <title>log4javascript lite demo</title>
|
| 6 | <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
|
| 7 | <meta name="author" content="Tim Down - tim@log4javascript.org" />
|
| 8 | <meta name="description" content="log4javascript, a logging framework for JavaScript based on log4j" />
|
| 9 | <meta name="robots" content="all" />
|
| 10 | <link rel="stylesheet" type="text/css" media="screen,print" href="../main.css" title="Default" />
|
| 11 | <script type="text/javascript" src="../js/log4javascript_lite.js"></script>
|
| 12 | <script type="text/javascript">
|
| 13 | // <![CDATA[
|
| 14 | var log = log4javascript.getDefaultLogger();
|
| 15 | log.debug("This is debugging message from the log4javascript lite demo page");
|
| 16 |
|
| 17 | var words = ["Boothroyd", "who", "took", "over", "two", "years",
|
| 18 | "ago", "and", "continues", "to", "maintain", "that", "the",
|
| 19 | "club", "are", "building", "for", "the", "future", "made",
|
| 20 | "six", "changes", "and", "gave", "a", "first", "Premiership",
|
| 21 | "start", "to", "on-loan", "Brazilian", "midfielder",
|
| 22 | "Douglas", "Rinaldi", "Darius", "Henderson", "and", "Steve",
|
| 23 | "Kabba", "were", "two", "of", "the", "players", "restored",
|
| 24 | "to", "the", "home", "side", "and", "were", "responsible",
|
| 25 | "for", "giving", "Chelsea", "an", "uncomfortable", "start",
|
| 26 | "which", "set", "the", "pattern", "for", "the", "match"
|
| 27 | ];
|
| 28 |
|
| 29 | var loaded = false;
|
| 30 |
|
| 31 | function generateRandom() {
|
| 32 | var numberOfEntries = parseInt(document.getElementById("numberOfLogEntries").value);
|
| 33 | for (var i = 0; i < numberOfEntries; i++) {
|
| 34 | var numberOfWords = 1 + Math.floor(10 * Math.random());
|
| 35 | var entryWords = [];
|
| 36 | for (var j = 0; j < numberOfWords; j++) {
|
| 37 | entryWords.push(words[Math.floor(Math.random() * words.length)]);
|
| 38 | }
|
| 39 | var entryMessage = entryWords.join(" ");
|
| 40 | var levelNum = Math.floor(Math.random() * 6);
|
| 41 | switch (levelNum) {
|
| 42 | case 0:
|
| 43 | log.trace(entryMessage);
|
| 44 | break;
|
| 45 | case 1:
|
| 46 | log.debug(entryMessage);
|
| 47 | break;
|
| 48 | case 2:
|
| 49 | log.info(entryMessage);
|
| 50 | break;
|
| 51 | case 3:
|
| 52 | log.warn(entryMessage);
|
| 53 | break;
|
| 54 | case 4:
|
| 55 | log.error(entryMessage);
|
| 56 | break;
|
| 57 | case 5:
|
| 58 | log.fatal(entryMessage);
|
| 59 | break;
|
| 60 | }
|
| 61 | }
|
| 62 | }
|
| 63 |
|
| 64 | function generateObjectExpansion() {
|
| 65 | var debugObj = {
|
| 66 | a: {
|
| 67 | b: "stuff",
|
| 68 | c: 3,
|
| 69 | d: {
|
| 70 | e: ["a", "b", "c"]
|
| 71 | }
|
| 72 | },
|
| 73 | f: "Things",
|
| 74 | g: 5
|
| 75 | };
|
| 76 | log.debug(debugObj);
|
| 77 | }
|
| 78 |
|
| 79 | function generateError() {
|
| 80 | try {
|
| 81 | throw new Error("Made up error");
|
| 82 | } catch (ex) {
|
| 83 | log.error("Logging an error!", ex);
|
| 84 | }
|
| 85 | }
|
| 86 | // ]]>
|
| 87 | </script>
|
| 88 | </head>
|
| 89 | <body onload="loaded = true; document.getElementById('enabled').checked = true;">
|
| 90 | <div id="container" class="nonav">
|
| 91 | <div id="header">
|
| 92 | <h1><a href="/docs/index.html">log4javascript</a></h1>
|
| 93 | </div>
|
| 94 | <div id="content">
|
| 95 | <div id="nav">
|
| 96 | <a class="navitem" href="http://sourceforge.net/projects/log4javascript" target="_blank" title="Download (opens in new window)">download</a>
|
| 97 | | <a class="navitem" href="../docs/index.html">docs</a>
|
| 98 | | <a class="navitem" href="../docs/quickstart.html">quick start</a>
|
| 99 | | <a class="navitem" href="../docs/manual.html">manual</a>
|
| 100 | | <a class="navitem" href="index.html">demos</a>
|
| 101 | | <a class="navitem" href="http://www.timdown.co.uk/log4javascript" target="_blank">website</a>
|
| 102 | </div>
|
| 103 | <h1>log4javascript lite demo</h1>
|
| 104 | <p>
|
| 105 | <em><strong>NB.</strong> Since the demo below uses pop-up windows, you will
|
| 106 | need to disable any pop-up blockers you may have for it to work.</em>
|
| 107 | </p>
|
| 108 | <p>
|
| 109 | This demo demonstrates the lite edition of log4javascript.
|
| 110 | </p>
|
| 111 | <p>
|
| 112 | Enter a log message below and click on one of the buttons to log
|
| 113 | your message at your desired level.
|
| 114 | </p>
|
| 115 | <div class="example">
|
| 116 | <input type="text" id="logText" value="Put log message here" />
|
| 117 | <input type="button" value="trace" onclick="log.trace(document.getElementById('logText').value)" />
|
| 118 | <input type="button" value="debug" onclick="log.debug(document.getElementById('logText').value)" />
|
| 119 | <input type="button" value="info" onclick="log.info(document.getElementById('logText').value)" />
|
| 120 | <input type="button" value="warn" onclick="log.warn(document.getElementById('logText').value)" />
|
| 121 | <input type="button" value="error" onclick="log.error(document.getElementById('logText').value)" />
|
| 122 | <input type="button" value="fatal" onclick="log.fatal(document.getElementById('logText').value)" />
|
| 123 | <br />
|
| 124 | Generate <input type="text" size="5" id="numberOfLogEntries" value="50" /> random log entries
|
| 125 | <input type="button" value="go" onclick="generateRandom()" />
|
| 126 | <br />
|
| 127 | <input type="button" value="Log exception" onclick="generateError()" />
|
| 128 | <input type="button" value="Log example object" onclick="generateObjectExpansion()" />
|
| 129 | <br />
|
| 130 | <input type="checkbox" id="enabled" onclick="log4javascript.setEnabled(this.checked)" checked="checked" /> <label for="enabled">logging enabled</label>
|
| 131 | <br />
|
| 132 | </div>
|
| 133 | </div>
|
| 134 | <br class="clear" />
|
| 135 | <div id="footer">
|
| 136 | <span class="externallinkinfo">
|
| 137 | <strong>NB.</strong> All external links open in a new window.
|
| 138 | </span>
|
| 139 | Written by Tim Down. <a href="mailto:tim@log4javascript.org">tim@log4javascript.org</a>
|
| 140 | <br />
|
| 141 | log4javascript is distributed under the <a href="http://www.apache.org/licenses/LICENSE-2.0.html"
|
| 142 | title="Apache License, Version 2.0 (opens in new window)" target="_blank">Apache License,
|
| 143 | Version 2.0</a>
|
| 144 |
|
| 145 | </div>
|
| 146 | </div>
|
| 147 | </body>
|
| 148 | </html>
|