Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 3485

Show
Ignore:
Timestamp:
05/04/08 19:30:14 (7 months ago)
Author:
kris
Message:

Reworked the log package to be cleaner, tighter, leaner, and more usable

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/example/cluster/alert.d

    r2467 r3485  
    11private import  tango.core.Thread; 
    22 
    3 private import  tango.util.log.Configurator; 
     3private import  tango.util.log.Log, 
     4                tango.util.log.Config; 
    45 
    56private import  tango.net.cluster.NetworkAlert; 
  • trunk/example/cluster/cclient.d

    r2978 r3485  
    66import tango.io.Stdout; 
    77 
     8import tango.util.log.Log, 
     9       tango.util.log.Config; 
     10 
    811import tango.time.StopWatch; 
    9  
    10 import tango.util.log.Configurator; 
    1112 
    1213import tango.net.cluster.NetworkCache; 
     
    2223{ 
    2324        StopWatch w; 
    24  
     25         
    2526        if (args.length > 1) 
    2627           { 
  • trunk/example/cluster/invalidate.d

    r2467 r3485  
    11private import  tango.core.Thread; 
    22 
    3 private import  tango.util.log.Configurator; 
     3private import  tango.util.log.Log, 
     4                tango.util.log.Config; 
    45 
    56private import  tango.net.cluster.tina.Cluster; 
  • trunk/example/cluster/qclient.d

    r2978 r3485  
    66import tango.io.Stdout; 
    77 
     8import tango.util.log.Log, 
     9       tango.util.log.Config; 
     10 
    811import tango.time.StopWatch; 
    9  
    10 import tango.util.log.Configurator; 
    1112 
    1213import tango.net.cluster.NetworkQueue; 
  • trunk/example/cluster/qlisten.d

    r2467 r3485  
    11private import  tango.core.Thread; 
    22 
    3 private import  tango.util.log.Configurator; 
     3private import  tango.util.log.Log, 
     4                tango.util.log.Config; 
    45 
    56private import  tango.net.cluster.NetworkQueue; 
     
    2021                       event.log.info ("received asynch msg on channel " ~ event.channel.name); 
    2122        } 
    22                  
    2323 
    2424        // join the cluster  
  • trunk/example/cluster/qrequest.d

    r2468 r3485  
    1 private import  tango.util.log.Configurator; 
     1private import  tango.util.log.Log, 
     2                tango.util.log.Config; 
    23 
    34private import  tango.net.cluster.NetworkQueue; 
  • trunk/example/cluster/reply.d

    r2467 r3485  
    11private import  tango.core.Thread; 
    22 
    3 private import  tango.util.log.Configurator; 
     3private import  tango.util.log.Log, 
     4                tango.util.log.Config; 
    45 
    56private import  tango.net.cluster.tina.Cluster; 
  • trunk/example/cluster/tclient.d

    r2978 r3485  
    88import tango.io.Stdout; 
    99 
     10import tango.util.log.Log, 
     11       tango.util.log.Config; 
     12 
    1013import tango.time.StopWatch; 
    11  
    12 import tango.util.log.Configurator; 
    1314 
    1415import tango.net.cluster.tina.ClusterTask; 
  • trunk/example/logging/chainsaw.d

    r2465 r3485  
    22 
    33import  tango.util.log.Log, 
    4         tango.util.log.Log4Layout, 
    5         tango.util.log.SocketAppender
     4        tango.util.log.AppendSocket, 
     5        tango.util.log.LayoutChainsaw
    66 
    77import  tango.net.InternetAddress; 
     
    1818{ 
    1919        // get a logger to represent this module 
    20         auto logger = Log.getLogger ("example.chainsaw"); 
     20        auto logger = Log.lookup ("example.chainsaw"); 
    2121 
    2222        // hook up an appender for XML output 
    23         logger.addAppender (new SocketAppender (new InternetAddress("127.0.0.1", 4448), new Log4Layout)); 
     23        logger.add (new AppendSocket (new InternetAddress("127.0.0.1", 4448), new LayoutChainsaw)); 
    2424 
    2525        while (true) 
  • trunk/example/logging/logging.d

    r2913 r3485  
    55*******************************************************************************/ 
    66 
    7 private import tango.util.log.Log, 
    8                tango.util.log.Configurator
     7import tango.util.log.Log, 
     8       tango.util.log.Config
    99 
    1010/******************************************************************************* 
     
    1515 
    1616void compute (Logger log, uint max) 
    17        
     17
    1818                byte*   feld; 
    1919                int     teste=1, 
     
    2323                        e = 1; 
    2424                int     count; 
    25                 char    tmp[128] = void; 
    2625 
    2726                void set (byte* f, uint x) 
     
    3534                } 
    3635 
     36                // get a log formatting instance 
     37                auto format = Log.format; 
     38 
    3739                // information level 
    38                 log.info (log.format (tmp, "Searching prime numbers up to {}", max)); 
     40                log.info (format ("Searching prime numbers up to {}", max)); 
    3941 
    4042                feld = (new byte[max / 16 + 1]).ptr; 
    41  
    42                 // get milliseconds since application began 
    43                 auto begin = log.runtime; 
    4443 
    4544                while ((teste += 2) < max) 
     
    4847                           if  ((++hits & 0x0f) == 0)  
    4948                                // more information level 
    50                                 log.info (log.format (tmp, "found {}", hits));  
     49                                log.info (format ("found {}", hits));  
    5150 
    5251                           for (mom=3*teste; mom < max; mom += teste<<1)  
     
    5453                           } 
    5554 
    56                 // get number of milliseconds we took to compute 
    57                 auto period = log.runtime - begin; 
    58  
    5955                if (hits) 
    6056                    // more information 
    61                     log.info (log.format (tmp, "{} prime numbers found in {} millsecs", hits, period)); 
     57                    log.info (format ("{} prime numbers found", hits)); 
    6258                else 
    6359                   // a warning level 
     
    6662                // check to see if we're enabled for  
    6763                // tracing before we expend a lot of effort 
    68                 if (log.isEnabled (log.Level.Trace)) 
     64                if (log.enabled (Level.Trace)) 
    6965                   {         
    7066                   e = max; 
     
    7672                           // log trace information 
    7773                           if (! test (feld, count))  
    78                                  log.trace (log.format (tmp, "prime found: {}", count)); 
     74                                 log.trace (format ("prime found: {}", count)); 
    7975                   } 
    8076} 
     
    8985void main() 
    9086{ 
    91         // get a logger to represent this module. We could just as 
    92         // easily share a name with some other module(s) 
    93         auto log = Log.getLogger ("example.logging"); 
     87        // get a logger to represent this module 
     88        auto log = Log.lookup ("example.logging"); 
    9489        try { 
    9590            compute (log, 1000); 
    96  
    9791            } catch (Exception x) 
    9892                    { 
    99                     // log the exception as an error 
    100                     log.error ("Exception: " ~ x.toString); 
     93                    // log the exception as a fatal error 
     94                    log.fatal ("Exception: " ~ x.toString); 
    10195                    } 
    10296} 
  • trunk/example/logging/multilog.d

    r3083 r3485  
    11import tango.util.log.Log; 
    2 import tango.util.log.Log4Layout
    3 import tango.util.log.FileAppender
    4 import tango.util.log.ConsoleAppender
    5 import tango.util.log.RollingFileAppender
     2import tango.util.log.AppendFile
     3import tango.util.log.AppendFiles
     4import tango.util.log.AppendConsole
     5import tango.util.log.LayoutChainsaw
    66 
    77/******************************************************************************* 
     
    1414{ 
    1515        // set default logging level at the root 
    16         auto log = Log.getRootLogger
    17         log.setLevel (log.Level.Trace)
     16        auto log = Log.root
     17        log.level = Level.Trace
    1818 
    1919        // 10 logs, all with 10 mbs each 
    20         log.addAppender (new RollingFileAppender("rolling.log", 9, 1024*1024*10)); 
     20        log.add (new AppendFiles ("rolling.log", 9, 1024*1024*10)); 
    2121 
    2222        // a single file appender, with an XML layout 
    23         log.addAppender (new FileAppender ("single.log", new Log4Layout)); 
     23        log.add (new AppendFile ("single.log", new LayoutChainsaw)); 
    2424 
    2525        // console appender 
    26         log.addAppender (new ConsoleAppender); 
     26        log.add (new AppendConsole); 
    2727 
    2828        // log to all 
  • trunk/example/networking/selector.d

    r2983 r3485  
    2626    import tango.net.ServerSocket; 
    2727    import tango.time.Clock; 
    28     import tango.util.log.Log; 
    29     import tango.util.log.ConsoleAppender; 
    30     import tango.util.log.DateLayout; 
    3128    import tango.text.convert.Sprint; 
    3229    import tango.core.Exception; 
     
    3431    import tango.sys.Common; 
    3532    import tango.stdc.errno; 
     33    import tango.util.log.Log; 
     34    import tango.util.log.LayoutDate; 
     35    import tango.util.log.AppendConsole; 
    3636} 
    3737 
     
    4646int main(char[][] args) 
    4747{ 
    48     Logger          log     = Log.getLogger("selector"); 
     48    Logger          log     = Log.lookup("selector"); 
    4949    Sprint!(char)   sprint  = new Sprint!(char)(256); 
    5050 
    51     log.addAppender(new ConsoleAppender(new DateLayout())); 
     51    log.add (new AppendConsole(new LayoutDate)); 
    5252 
    5353    ISelector selector; 
  • trunk/example/text/xmldom.d

    r3324 r3485  
    1212import tango.time.StopWatch; 
    1313import tango.text.xml.Document; 
     14import tango.text.xml.DocPrinter; 
    1415 
    1516/******************************************************************************* 
     
    2223 
    2324        auto doc = new Document!(char); 
    24         auto content = cast (char[]) File("hamlet.xml").read; 
     25        auto content = cast (char[]) File("test.xml").read; 
    2526 
    2627        elapsed.start; 
     
    2829             doc.parse (content); 
    2930 
    30         Stdout.formatln ("{} MB/s", (content.length * iterations) / (elapsed.stop * (1024 * 1024))); 
     31        foreach (node; doc.query.descendant("xyz")) 
     32                 node.detach; 
     33 
     34        auto print = new DocPrinter!(char); 
     35        Stdout (print (doc)).newline; 
     36//        Stdout.formatln ("{} MB/s", (content.length * iterations) / (elapsed.stop * (1024 * 1024))); 
    3137} 
    3238         
     
    3743void main() 
    3844{ 
    39         for (int i=10; i--;) 
     45        for (int i=1; i--;) 
    4046             bench (2000); 
    4147} 
  • trunk/tango/group/log.d

    r3410 r3485  
    1818 
    1919public import tango.util.log.Log; 
    20 public import tango.util.log.Logger; 
    21 public import tango.util.log.Hierarchy; 
    22 public import tango.util.log.DateLayout; 
    23 public import tango.util.log.Log4Layout; 
    24 public import tango.util.log.EventLayout; 
    25 public import tango.util.log.FileAppender; 
    26 public import tango.util.log.MailAppender; 
    27 public import tango.util.log.SocketAppender; 
    28 public import tango.util.log.ConsoleAppender; 
    29 public import tango.util.log.RollingFileAppender; 
     20public import tango.util.log.LayoutDate; 
     21public import tango.util.log.LayoutChainsaw; 
     22public import tango.util.log.AppendFile; 
     23public import tango.util.log.AppendMail; 
     24public import tango.util.log.AppendSocket; 
     25public import tango.util.log.AppendFiles; 
    3026                 
    3127 
  • trunk/tango/net/cluster/NetworkClient.d

    r3038 r3485  
    104104        ***********************************************************************/ 
    105105         
    106         Logger log () 
     106        ILogger log () 
    107107        { 
    108108                return cluster_.log; 
  • trunk/tango/net/cluster/model/IChannel.d

    r2809 r3485  
    1313module tango.net.cluster.model.IChannel; 
    1414 
    15 private import  tango.util.log.Logger; 
     15private import  tango.util.log.model.ILogger; 
    1616 
    1717private import  tango.net.cluster.model.IMessage, 
     
    3636        ***********************************************************************/ 
    3737         
    38         Logger log (); 
     38        ILogger log (); 
    3939 
    4040        /*********************************************************************** 
     
    190190        ***********************************************************************/ 
    191191         
    192         Logger log (); 
     192        ILogger log (); 
    193193} 
    194194 
  • trunk/tango/net/cluster/model/ICluster.d

    r2809 r3485  
    1313module tango.net.cluster.model.ICluster; 
    1414 
    15 public  import  tango.util.log.Logger; 
     15public  import  tango.util.log.model.ILogger; 
    1616 
    1717public  import  tango.net.cluster.model.IChannel, 
     
    4545        ***********************************************************************/ 
    4646         
    47         Logger log (); 
     47        ILogger log (); 
    4848} 
  • trunk/tango/net/cluster/tina/Cluster.d

    r2983 r3485  
    1919                tango.core.Exception; 
    2020 
    21 private import  tango.util.log.Log, 
    22                 tango.util.log.Logger; 
     21private import  tango.util.log.Log; 
    2322 
    2423private import  tango.time.Clock; 
  • trunk/tango/net/cluster/tina/ClusterQueue.d

    r2932 r3485  
    2727class ClusterQueue 
    2828{ 
    29         private Logger          log; 
     29        private ILogger         log; 
    3030        private uint            used,  
    3131                                limit; 
  • trunk/tango/net/cluster/tina/CmdParser.d

    r3416 r3485  
    1313module tango.net.cluster.tina.CmdParser; 
    1414 
     15private import  tango.util.log.Log, 
     16                tango.util.log.Config; 
     17 
    1518private import  tango.util.Arguments; 
    1619 
    1720private import  tango.text.convert.Integer; 
    18  
    19 private import  tango.util.log.Log, 
    20                 tango.util.log.Configurator; 
    2121 
    2222/****************************************************************************** 
     
    3939        this (char[] name) 
    4040        { 
    41                 log = Log.getLogger (name); 
     41                log = Log.lookup (name); 
    4242 
    4343                // default logging is info, not trace 
    44                 log.setLevel (log.Level.Info)
     44                log.level = Level.Info
    4545        } 
    4646 
     
    6161                    help = true; 
    6262                if (this.contains("log")) 
    63                     log.setLevel(Log.level(this["log"])); 
     63                    log.level = Log.convert(this["log"]); 
    6464                if (this.contains("port")) 
    6565                    port = cast(ushort)atoi(this["port"]); 
  • trunk/tango/net/cluster/tina/QueueFile.d

    r2978 r3485  
    1616                tango.io.FileConduit; 
    1717 
    18 private import  tango.util.log.Logger; 
     18private import  tango.util.log.model.ILogger; 
    1919 
    2020private import  tango.text.convert.Sprint; 
     
    4141        } 
    4242 
    43         private Logger          log;            // logging target 
     43        private ILogger         log;            // logging target 
    4444        private bool            dirty;          // is queue dirty? 
    4545        private uint            limit,          // max file size 
     
    5656        **********************************************************************/ 
    5757 
    58         this (Logger log, IChannel channel, uint max, uint min=1024*1024) 
     58        this (ILogger log, IChannel channel, uint max, uint min=1024*1024) 
    5959        { 
    6060                this (log, channel.name~".queue", max, min); 
     
    6666        **********************************************************************/ 
    6767 
    68         this (Logger log, char[] name, uint max, uint min=1024*1024) 
     68        this (ILogger log, char[] name, uint max, uint min=1024*1024) 
    6969        { 
    7070                Header tmp; 
  • trunk/tango/util/log/Config.d

    r2809 r3485  
    1111*******************************************************************************/ 
    1212 
    13 module tango.util.log.Configurator
     13module tango.util.log.Config
    1414 
    1515private import  tango.util.log.Log, 
    16                 tango.util.log.EventLayout, 
    17                 tango.util.log.ConsoleAppender; 
     16                tango.util.log.AppendConsole; 
    1817 
    1918/******************************************************************************* 
    2019 
    21         Basic utility for initializing the basic behaviour of the 
    22         default logging hierarchy. 
     20        Utility for initializing the basic behaviour of the default 
     21        logging hierarchy. 
    2322 
    24         Adds a default StdioAppender, with a SimpleTimerLayout, to  
    25         the root node, and set the activity level to be everything  
    26         enabled. 
     23        Adds a default console appender with a generic layout to the  
     24        root node, and set the activity level to be everything enabled 
    2725                 
    2826*******************************************************************************/ 
    2927 
    30 static this() 
     28static this () 
    3129{ 
    32         Log.getRootLogger.addAppender(new ConsoleAppender(new SimpleTimerLayout)); 
     30        Log.root.add (new AppendConsole (new LayoutTimer)); 
    3331} 
    34  
    35  
    36  
    37 /******************************************************************************* 
    38  
    39 *******************************************************************************/ 
    40  
    41 public class Configurator 
    42 { 
    43         /*********************************************************************** 
    44  
    45                 No longer required. Just import this module instead 
    46  
    47         ***********************************************************************/ 
    48  
    49         deprecated static void opCall () 
    50         { 
    51         } 
    52 } 
    53  
  • trunk/tango/util/log/Log.d

    r3029 r3485  
    1010        author:         Kris 
    1111 
     12 
     13        Loggers are named entities, sometimes shared, sometimes specific to  
     14        a particular portion of code. The names are generally hierarchical in  
     15        nature, using dot notation (with '.') to separate each named section.  
     16        For example, a typical name might be something like "mail.send.writer" 
     17        --- 
     18        import tango.util.log.Log; 
     19         
     20        auto log = Log.lookup ("mail.send.writer"); 
     21 
     22        log.info  ("an informational message"); 
     23        log.error ("an exception message: " ~ exception.toString); 
     24 
     25        etc ... 
     26        --- 
     27         
     28        It is considered good form to pass a logger instance as a function or  
     29        class-ctor argument, or to assign a new logger instance during static  
     30        class construction. For example: if it were considered appropriate to  
     31        have one logger instance per class, each might be constructed like so: 
     32        --- 
     33        private Logger log; 
     34         
     35        static this() 
     36        { 
     37            log = Log.lookup (nameOfThisClassOrStructOrModule); 
     38        } 
     39        --- 
     40 
     41        Messages passed to a Logger are assumed to be pre-formatted. You  
     42        may find that the format() methos is handy for collating various  
     43        components of the message:  
     44        --- 
     45        auto format = Log.format; 
     46        ... 
     47        log.warn (format ("temperature is {} degrees!", 101)); 
     48        --- 
     49 
     50        Note that a provided workspace is used to format the message, which  
     51        should generally be located on the stack so as to support multiple 
     52        threads of execution. In the example above we indicate assignment as  
     53        "tmp = void", although this is an optional attribute (see the language  
     54        manual for more information). 
     55 
     56        To avoid overhead when constructing formatted messages, the logging 
     57        system employs lazy expressions such that the message is not constructed 
     58        unless the logger is actually active. You can also explicitly check to 
     59        see whether a logger is active or not: 
     60        --- 
     61        if (log.isEnabled (log.Level.Warn)) 
     62            log.warn (format ("temperature is {} degrees!", 101)); 
     63        --- 
     64 
     65        You might optionally configure various layout & appender implementations 
     66        to support specific rendering needs. 
     67         
     68        tango.log closely follows both the API and the behaviour as documented  
     69        at the official Log4J site, where you'll find a good tutorial. Those  
     70        pages are hosted over  
     71        <A HREF="http://logging.apache.org/log4j/docs/documentation.html">here</A>. 
     72 
    1273*******************************************************************************/ 
    1374 
    1475module tango.util.log.Log; 
    1576 
    16 public  import  tango.util.log.Logger; 
    17  
    18 private import  tango.util.log.Event, 
    19                 tango.util.log.Hierarchy; 
    20  
    21 private import  tango.util.log.model.ILevel; 
     77private import  tango.sys.Common; 
     78 
     79private import  tango.time.Clock; 
     80 
     81private import  tango.core.Exception; 
     82 
     83private import  tango.io.model.IConduit; 
     84 
     85private import  tango.text.convert.Format; 
     86 
     87private import  tango.util.log.model.ILogger; 
     88 
     89/******************************************************************************* 
     90 
     91        Pull in additional functions from the C library 
     92 
     93*******************************************************************************/ 
     94 
     95extern (C) 
     96
     97        private int memcmp (void *, void *, int); 
     98
     99 
     100version (Win32) 
     101
     102        private extern(Windows) int QueryPerformanceCounter(ulong *count); 
     103        private extern(Windows) int QueryPerformanceFrequency(ulong *frequency); 
     104
     105 
     106/******************************************************************************* 
     107                         
     108        These represent the standard LOG4J event levels. Note that 
     109        Debug is called Trace here, because debug is a reserved word 
     110        in D  
     111 
     112*******************************************************************************/ 
     113 
     114alias ILogger.Level Level;  
     115 
    22116 
    23117/******************************************************************************* 
     
    30124*******************************************************************************/ 
    31125 
    32 class Log : ILevel 
     126public struct Log 
    33127{ 
    34         static private  Hierarchy base; 
    35  
    36         private static  ILevel.Level[char[]] map; 
    37          
    38         private struct  Pair {char[] name; ILevel.Level value;} 
    39  
     128        // support for old API 
     129        public alias lookup getLogger; 
     130 
     131        // internal use only 
     132        private static Hierarchy base; 
     133        private static Time beginTime; 
     134 
     135        version (Win32) 
     136        { 
     137                private static double multiplier; 
     138                private static ulong  timerStart; 
     139        } 
     140 
     141        private struct  Pair {char[] name; Level value;} 
     142 
     143        private static  Level [char[]] map; 
     144         
    40145        private static  Pair[] Pairs =  
    41146                        [ 
    42                         {"TRACE",  ILevel.Level.Trace}, 
    43                         {"Trace",  ILevel.Level.Trace}, 
    44                         {"trace",  ILevel.Level.Trace}, 
    45                         {"INFO",   ILevel.Level.Info}, 
    46                         {"Info",   ILevel.Level.Info}, 
    47                         {"info",   ILevel.Level.Info}, 
    48                         {"WARN",   ILevel.Level.Warn}, 
    49                         {"Warn",   ILevel.Level.Warn}, 
    50                         {"warn",   ILevel.Level.Warn}, 
    51                         {"ERROR",  ILevel.Level.Error}, 
    52                         {"Error",  ILevel.Level.Error}, 
    53                         {"error",  ILevel.Level.Error}, 
    54                         {"Fatal",  ILevel.Level.Fatal}, 
    55                         {"FATAL",  ILevel.Level.Fatal}, 
    56                         {"fatal",  ILevel.Level.Fatal}, 
    57                         {"NONE",   ILevel.Level.None}, 
    58                         {"None",   ILevel.Level.None}, 
    59                         {"none",   ILevel.Level.None}, 
     147                        {"TRACE",  Level.Trace}, 
     148                        {"Trace",  Level.Trace}, 
     149                        {"trace",  Level.Trace}, 
     150                        {"INFO",   Level.Info}, 
     151                        {"Info",   Level.Info}, 
     152                        {"info",   Level.Info}, 
     153                        {"WARN",   Level.Warn}, 
     154                        {"Warn",   Level.Warn}, 
     155                        {"warn",   Level.Warn}, 
     156                        {"ERROR",  Level.Error}, 
     157                        {"Error",  Level.Error}, 
     158                        {"error",  Level.Error}, 
     159                        {"Fatal",  Level.Fatal}, 
     160                        {"FATAL",  Level.Fatal}, 
     161                        {"fatal",  Level.Fatal}, 
     162                        {"NONE",   Level.None}, 
     163                        {"None",   Level.None}, 
     164                        {"none",   Level.None}, 
    60165                        ]; 
    61166 
    62         /*********************************************************************** 
    63          
    64                 This is a singleton, so hide the constructor. 
    65  
    66         ***********************************************************************/ 
    67  
    68         private this () 
    69         { 
    70         } 
    71  
    72         /*********************************************************************** 
    73          
    74                 Initialize the base hierarchy.                 
     167        // logging-level names 
     168        private static char[][] LevelNames =  
     169        [ 
     170                "Trace ", "Info  ", "Warn  ", "Error ", "Fatal ", "None  " 
     171        ]; 
     172 
     173        /*********************************************************************** 
     174         
     175                Initialize the base hierarchy            
    75176               
    76177        ***********************************************************************/ 
     
    79180        { 
    80181                base = new Hierarchy ("tango"); 
    81                 Event.initialize (); 
    82  
    83                 // populate a map of acceptable level names 
     182 
    84183                foreach (p; Pairs) 
    85184                         map[p.name] = p.value; 
     185 
     186                version (Posix)        
     187                { 
     188                        beginTime = Clock.now; 
     189                } 
     190 
     191                version (Win32) 
     192                { 
     193                        ulong freq; 
     194 
     195                        if (! QueryPerformanceFrequency (&freq)) 
     196                              throw new PlatformException ("high-resolution timer is not available"); 
     197                         
     198                        QueryPerformanceCounter (&timerStart); 
     199                        multiplier = cast(double) TimeSpan.TicksPerSecond / freq;        
     200                        beginTime = Clock.now; 
     201                } 
     202        } 
     203 
     204        /*********************************************************************** 
     205         
     206                Return the level of a given name 
     207 
     208        ***********************************************************************/ 
     209 
     210        static Level convert (char[] name, Level def=Level.Trace) 
     211        { 
     212                auto p = name in map; 
     213                if (p) 
     214                    return *p; 
     215                return def; 
     216        } 
     217 
     218        /*********************************************************************** 
     219                 
     220                Return the current time 
     221 
     222        ************************