 |
Changeset 3616
- Timestamp:
- 06/13/08 16:31:06
(6 months ago)
- Author:
- kris
- Message:
removed support for lazy delegates, since their usage is just too awkward
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3029 |
r3616 |
|
| 233 | 233 | Log.getRootLogger.addAppender(appender); |
|---|
| 234 | 234 | |
|---|
| 235 | | char[128] tmp = 0; |
|---|
| 236 | 235 | auto log = Log.getLogger("context"); |
|---|
| 237 | 236 | log.setLevel(log.Level.Info); |
|---|
| … | … | |
| 240 | 239 | //calls should count in the test. |
|---|
| 241 | 240 | for (int i=0;i < 10; i++) { |
|---|
| 242 | | log.info(log.format(tmp, "test1 {}", i)); |
|---|
| 243 | | log.trace(log.format(tmp, "test1 {}", i)); |
|---|
| | 241 | log.info("test1 {}", i); |
|---|
| | 242 | log.trace("test1 {}", i); |
|---|
| 244 | 243 | } |
|---|
| 245 | 244 | if (appender.events !is 10) { |
|---|
| 246 | | log.error(log.format(tmp, "events:{}", appender.events)); |
|---|
| | 245 | log.error("events:{}", appender.events); |
|---|
| 247 | 246 | throw new Exception("Incorrect Number of events in normal mode"); |
|---|
| 248 | 247 | } |
|---|
| … | … | |
| 255 | 254 | Log.getHierarchy.context(context); |
|---|
| 256 | 255 | for (int i=0;i < 10; i++) { |
|---|
| 257 | | log.info(log.format(tmp, "test2 {}", i)); |
|---|
| 258 | | log.trace(log.format(tmp, "test2 {}", i)); |
|---|
| | 256 | log.info(tmp, "test2 {}", i); |
|---|
| | 257 | log.trace("test2 {}", i); |
|---|
| 259 | 258 | } |
|---|
| 260 | 259 | if (appender.events !is 10) { |
|---|
| 261 | | log.error(log.format(tmp, "events:{}", appender.events)); |
|---|
| | 260 | log.error("events:{}", appender.events); |
|---|
| 262 | 261 | throw new Exception("Incorrect Number of events in TLS single thread mode"); |
|---|
| 263 | 262 | } |
|---|
| … | … | |
| 270 | 269 | context.setLevel(log.Level.Trace); |
|---|
| 271 | 270 | for (int i=0;i < 10; i++) { |
|---|
| 272 | | log.info(log.format(tmp, "test3 {}", i)); |
|---|
| 273 | | log.trace(log.format(tmp, "test3 {}", i)); |
|---|
| | 271 | log.info("test3 {}", i); |
|---|
| | 272 | log.trace("test3 {}", i); |
|---|
| 274 | 273 | } |
|---|
| 275 | 274 | if (appender.events !is 20) { |
|---|
| 276 | | log.error(log.format(tmp, "events:{}", appender.events)); |
|---|
| | 275 | log.error("events:{}", appender.events); |
|---|
| 277 | 276 | throw new Exception("Incorrect Number of events in TLS single thread mode with level set"); |
|---|
| 278 | 277 | } |
|---|
| … | … | |
| 283 | 282 | context.setLevel(log.Level.None); |
|---|
| 284 | 283 | for (int i=0;i < 10; i++) { |
|---|
| 285 | | log.info(log.format(tmp, "test4 {}", i)); |
|---|
| 286 | | log.trace(log.format(tmp, "test4 {}", i)); |
|---|
| | 284 | log.info("test4 {}", i); |
|---|
| | 285 | log.trace("test4 {}", i); |
|---|
| 287 | 286 | } |
|---|
| 288 | 287 | if (appender.events !is 10) { |
|---|
| 289 | | log.error(log.format(tmp, "events:{}", appender.events)); |
|---|
| | 288 | log.error("events:{}", appender.events); |
|---|
| 290 | 289 | throw new Exception("Incorrect Number of events in TLS single thread mode after level reset"); |
|---|
| 291 | 290 | } |
|---|
| … | … | |
| 296 | 295 | ThreadGroup tg = new ThreadGroup(); |
|---|
| 297 | 296 | tg.create({ |
|---|
| 298 | | char[128] tmp = 0; |
|---|
| 299 | 297 | context.setLevel(log.Level.Trace); |
|---|
| 300 | 298 | context.push("specialthread"); |
|---|
| 301 | 299 | context.push("2ndlevel"); |
|---|
| 302 | 300 | for (int i=0;i < 10; i++) { |
|---|
| 303 | | log.info(log.format(tmp, "test5 {}", i)); |
|---|
| 304 | | log.trace(log.format(tmp, "test5 {}", i)); |
|---|
| | 301 | log.info("test5 {}", i); |
|---|
| | 302 | log.trace("test5 {}", i); |
|---|
| 305 | 303 | } |
|---|
| 306 | 304 | }); |
|---|
| 307 | 305 | tg.create({ |
|---|
| 308 | | char[128] tmp = 0; |
|---|
| 309 | 306 | context.setLevel(log.Level.None); |
|---|
| 310 | 307 | for (int i=0;i < 10; i++) { |
|---|
| 311 | | log.info(log.format(tmp, "test6 {}", i)); |
|---|
| 312 | | log.trace(log.format(tmp, "test6 {}", i)); |
|---|
| | 308 | log.info("test6 {}", i); |
|---|
| | 309 | log.trace("test6 {}", i); |
|---|
| 313 | 310 | } |
|---|
| 314 | 311 | }); |
|---|
| … | … | |
| 316 | 313 | |
|---|
| 317 | 314 | if (appender.events !is 30) { |
|---|
| 318 | | log.error(log.format(tmp, "events:{}", appender.events)); |
|---|
| | 315 | log.error("events:{}", appender.events); |
|---|
| 319 | 316 | throw new Exception("Incorrect Number of events in TLS multi thread mode"); |
|---|
| 320 | 317 | } |
|---|
| r3485 |
r3616 |
|
| 34 | 34 | } |
|---|
| 35 | 35 | |
|---|
| 36 | | // get a log formatting instance |
|---|
| 37 | | auto format = Log.format; |
|---|
| 38 | | |
|---|
| 39 | 36 | // information level |
|---|
| 40 | | log.info (format ("Searching prime numbers up to {}", max)); |
|---|
| | 37 | log.info ("Searching prime numbers up to {}", max); |
|---|
| 41 | 38 | |
|---|
| 42 | 39 | feld = (new byte[max / 16 + 1]).ptr; |
|---|
| … | … | |
| 47 | 44 | if ((++hits & 0x0f) == 0) |
|---|
| 48 | 45 | // more information level |
|---|
| 49 | | log.info (format ("found {}", hits)); |
|---|
| | 46 | log.info ("found {}", hits); |
|---|
| 50 | 47 | |
|---|
| 51 | 48 | for (mom=3*teste; mom < max; mom += teste<<1) |
|---|
| … | … | |
| 55 | 52 | if (hits) |
|---|
| 56 | 53 | // more information |
|---|
| 57 | | log.info (format ("{} prime numbers found", hits)); |
|---|
| | 54 | log.info ("{} prime numbers found", hits); |
|---|
| 58 | 55 | else |
|---|
| 59 | 56 | // a warning level |
|---|
| … | … | |
| 72 | 69 | // log trace information |
|---|
| 73 | 70 | if (! test (feld, count)) |
|---|
| 74 | | log.trace (format ("prime found: {}", count)); |
|---|
| | 71 | log.trace ("prime found: {}", count); |
|---|
| 75 | 72 | } |
|---|
| 76 | 73 | } |
|---|
| r3572 |
r3616 |
|
| 5 | 5 | license: BSD style: $(LICENSE) |
|---|
| 6 | 6 | |
|---|
| 7 | | version: Initial release: May 2004 |
|---|
| 8 | | version: Hierarchy moved due to circular dependencies; Oct 2004 |
|---|
| 9 | | |
|---|
| | 7 | version: May 2004 : Initial release |
|---|
| | 8 | version: Oct 2004: Hierarchy moved due to circular dependencies |
|---|
| | 9 | version: Apr 2008: Lazy delegates removed due to awkward usage |
|---|
| 10 | 10 | author: Kris |
|---|
| 11 | 11 | |
|---|
| … | … | |
| 16 | 16 | For example, a typical name might be something like "mail.send.writer" |
|---|
| 17 | 17 | --- |
|---|
| 18 | | import tango.util.log.Log; |
|---|
| | 18 | import tango.util.log.Log;format |
|---|
| 19 | 19 | |
|---|
| 20 | 20 | auto log = Log.lookup ("mail.send.writer"); |
|---|
| 21 | 21 | |
|---|
| 22 | 22 | log.info ("an informational message"); |
|---|
| 23 | | log.error ("an exception message: " ~ exception.toString); |
|---|
| | 23 | log.error ("an exception message: {}", exception.toString); |
|---|
| 24 | 24 | |
|---|
| 25 | 25 | etc ... |
|---|
| … | … | |
| 39 | 39 | --- |
|---|
| 40 | 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 | | |
|---|
| | 41 | Messages passed to a Logger are assumed to be either self-contained |
|---|
| | 42 | or configured with "{}" notation a la Layout & Stdout: |
|---|
| | 43 | --- |
|---|
| | 44 | log.warn ("temperature is {} degrees!", 101); |
|---|
| | 45 | --- |
|---|
| | 46 | |
|---|
| | 47 | Note that an internal workspace is used to format the message, which |
|---|
| | 48 | is limited to 2000 bytes. Use "{.256}" truncation notation to limit |
|---|
| | 49 | the size of individual message components, or use explicit formatting: |
|---|
| | 50 | --- |
|---|
| | 51 | char[4096] buf = void; |
|---|
| | 52 | |
|---|
| | 53 | log.warn (log.format (buf, "a very long warning: {}", someLongWarning); |
|---|
| | 54 | --- |
|---|
| | 55 | |
|---|
| | 56 | To avoid overhead when constructing argument passed to formatted |
|---|
| | 57 | messages, you should check to see whether a logger is active or not: |
|---|
| | 58 | --- |
|---|
| | 59 | if (log.enabled (log.Level.Warn)) |
|---|
| | 60 | log.warn ("temperature is {} degrees!", complexFunction()); |
|---|
| | 61 | --- |
|---|
| | 62 | |
|---|
| | 63 | The above will be handled implicitly by the logging system when |
|---|
| | 64 | macros are added to the language (used to be handled implicitly |
|---|
| | 65 | via lazy delegates, but usage of those turned out to be awkward). |
|---|
| | 66 | |
|---|
| 68 | 67 | tango.log closely follows both the API and the behaviour as documented |
|---|
| 69 | 68 | at the official Log4J site, where you'll find a good tutorial. Those |
|---|
| … | … | |
| 328 | 327 | /*********************************************************************** |
|---|
| 329 | 328 | |
|---|
| 330 | | Format support for use with existing log instances. We have |
|---|
| 331 | | to do it this way because log instances are shared, and the |
|---|
| 332 | | formatting buffer must be on the stack instead (in order to |
|---|
| 333 | | avoid potential thread contention). Typical usage is: |
|---|
| 334 | | --- |
|---|
| 335 | | auto format = Log.format; |
|---|
| 336 | | ... |
|---|
| 337 | | log.trace (format ("{} trace {}", 'a', "message")); |
|---|
| 338 | | ... |
|---|
| 339 | | log.info (format ("{} {} {}", "an", "info", "message")); |
|---|
| 340 | | ... |
|---|
| 341 | | --- |
|---|
| 342 | | |
|---|
| 343 | | Setting a larger buffer size than the default (of 512): |
|---|
| 344 | | --- |
|---|
| 345 | | char[2048] buf = void; |
|---|
| 346 | | auto format = Log.format (buf); |
|---|
| 347 | | |
|---|
| 348 | | log.trace (format ("{} formatted {}", 'a', "string")); |
|---|
| 349 | | ... |
|---|
| 350 | | --- |
|---|
| 351 | | |
|---|
| 352 | | Note that this is a struct, and is thus allocated on the |
|---|
| 353 | | stack. Note also that the format() call is *not* invoked |
|---|
| 354 | | unless the log instance is actually enabled - meaning we |
|---|
| 355 | | pay only for what will be emitted. |
|---|
| 356 | | |
|---|
| 357 | | ***********************************************************************/ |
|---|
| 358 | | |
|---|
| 359 | | static Sprint format (char[] buffer = null) |
|---|
| 360 | | { |
|---|
| 361 | | Sprint sprint = void; |
|---|
| 362 | | |
|---|
| 363 | | if (buffer.length is 0) |
|---|
| 364 | | buffer = sprint.tmp; |
|---|
| 365 | | |
|---|
| 366 | | sprint.buffer = buffer; |
|---|
| 367 | | return sprint; |
|---|
| 368 | | } |
|---|
| 369 | | |
|---|
| 370 | | /*********************************************************************** |
|---|
| 371 | | |
|---|
| 372 | 329 | Initialize a snapshot for a specific logging level, and |
|---|
| 373 | 330 | with an optional buffer. Default buffer size is 1024 |
|---|
| … | … | |
| 375 | 332 | ***********************************************************************/ |
|---|
| 376 | 333 | |
|---|
| 377 | | static Snapshot snapshot (Logger owner, Level level, char[] buffer = null) |
|---|
| | 334 | static private Snapshot snapshot (Logger owner, Level level, char[] buffer = null) |
|---|
| 378 | 335 | { |
|---|
| 379 | 336 | assert (owner); |
|---|
| … | … | |
| 388 | 345 | snap.next = 0; |
|---|
| 389 | 346 | return snap; |
|---|
| 390 | | } |
|---|
| 391 | | |
|---|
| 392 | | /*********************************************************************** |
|---|
| 393 | | |
|---|
| 394 | | ***********************************************************************/ |
|---|
| 395 | | |
|---|
| 396 | | private struct Sprint |
|---|
| 397 | | { |
|---|
| 398 | | private char[] buffer; |
|---|
| 399 | | private char[512] tmp = void; |
|---|
| 400 | | |
|---|
| 401 | | char[] opCall (char[] formatStr, ...) |
|---|
| 402 | | { |
|---|
| 403 | | return Format.vprint (buffer, formatStr, _arguments, _argptr); |
|---|
| 404 | | } |
|---|
| 405 | 347 | } |
|---|
| 406 | 348 | } |
|---|
| … | … | |
| 435 | 377 | *******************************************************************************/ |
|---|
| 436 | 378 | |
|---|
| 437 | | public struct Snapshot |
|---|
| | 379 | private struct Snapshot |
|---|
| 438 | 380 | { |
|---|
| 439 | 381 | private Logger owner; |
|---|
| … | … | |
| 494 | 436 | For example, a typical name might be something like "mail.send.writer" |
|---|
| 495 | 437 | --- |
|---|
| 496 | | import tango.util.log.Log; |
|---|
| | 438 | import tango.util.log.Log;format |
|---|
| 497 | 439 | |
|---|
| 498 | 440 | auto log = Log.lookup ("mail.send.writer"); |
|---|
| 499 | 441 | |
|---|
| 500 | 442 | log.info ("an informational message"); |
|---|
| 501 | | log.error ("an exception message: " ~ exception.toString); |
|---|
| | 443 | log.error ("an exception message: {}", exception.toString); |
|---|
| 502 | 444 | |
|---|
| 503 | 445 | etc ... |
|---|
| … | … | |
| 517 | 459 | --- |
|---|
| 518 | 460 | |
|---|
| 519 | | Messages passed to a Logger are assumed to be pre-formatted. You |
|---|
| 520 | | may find that the format() methos is handy for collating various |
|---|
| 521 | | components of the message: |
|---|
| 522 | | --- |
|---|
| 523 | | auto format = Log.format; |
|---|
| 524 | | ... |
|---|
| 525 | | log.warn (format ("temperature is {} degrees!", 101)); |
|---|
| 526 | | --- |
|---|
| 527 | | |
|---|
| 528 | | Note that a provided workspace is used to format the message, which |
|---|
| 529 | | should generally be located on the stack so as to support multiple |
|---|
| 530 | | threads of execution. In the example above we indicate assignment as |
|---|
| 531 | | "tmp = void", although this is an optional attribute (see the language |
|---|
| 532 | | manual for more information). |
|---|
| 533 | | |
|---|
| 534 | | To avoid overhead when constructing formatted messages, the logging |
|---|
| 535 | | system employs lazy expressions such that the message is not constructed |
|---|
| 536 | | unless the logger is actually active. You can also explicitly check to |
|---|
| 537 | | see whether a logger is active or not: |
|---|
| 538 | | --- |
|---|
| 539 | | if (log.isEnabled (log.Level.Warn)) |
|---|
| 540 | | log.warn (format ("temperature is {} degrees!", 101)); |
|---|
| 541 | | --- |
|---|
| 542 | | |
|---|
| 543 | | You might optionally configure various layout & appender implementations |
|---|
| 544 | | to support specific rendering needs. |
|---|
| 545 | | |
|---|
| | 461 | Messages passed to a Logger are assumed to be either self-contained |
|---|
| | 462 | or configured with "{}" notation a la Layout & Stdout: |
|---|
| | 463 | --- |
|---|
| | 464 | log.warn ("temperature is {} degrees!", 101); |
|---|
| | 465 | --- |
|---|
| | 466 | |
|---|
| | 467 | Note that an internal workspace is used to format the message, which |
|---|
| | 468 | is limited to 2000 bytes. Use "{.256}" truncation notation to limit |
|---|
| | 469 | the size of individual message components, or use explicit formatting: |
|---|
| | 470 | --- |
|---|
| | 471 | char[4096] buf = void; |
|---|
| | 472 | |
|---|
| | 473 | log.warn (log.format (buf, "a very long warning: {}", someLongWarning); |
|---|
| | 474 | --- |
|---|
| | 475 | |
|---|
| | 476 | To avoid overhead when constructing argument passed to formatted |
|---|
| | 477 | messages, you should check to see whether a logger is active or not: |
|---|
| | 478 | --- |
|---|
| | 479 | if (log.enabled (log.Level.Warn)) |
|---|
| | 480 | log.warn ("temperature is {} degrees!", complexFunction()); |
|---|
| | 481 | --- |
|---|
| | 482 | |
|---|
| | 483 | The above will be handled implicitly by the logging system when |
|---|
| | 484 | macros are added to the language (used to be handled implicitly |
|---|
| | 485 | via lazy delegates, but usage of those turned out to be awkward). |
|---|
| | 486 | |
|---|
| 546 | 487 | tango.log closely follows both the API and the behaviour as documented |
|---|
| 547 | 488 | at the official Log4J site, where you'll find a good tutorial. Those |
|---|
| … | … | |
| 626 | 567 | ***********************************************************************/ |
|---|
| 627 | 568 | |
|---|
| 628 | | final Logger trace (lazy char[] msg) |
|---|
| 629 | | { |
|---|
| 630 | | return append (Level.Trace, msg); |
|---|
| | 569 | final Logger trace (char[] fmt, ...) |
|---|
| | 570 | { |
|---|
| | 571 | return format (Level.Trace, fmt, _arguments, _argptr); |
|---|
| 631 | 572 | } |
|---|
| 632 | 573 | |
|---|
| … | … | |
| 637 | 578 | ***********************************************************************/ |
|---|
| 638 | 579 | |
|---|
| 639 | | final void trace (lazy void dg) |
|---|
| | 580 | private void trace (lazy void dg) |
|---|
| 640 | 581 | { |
|---|
| 641 | 582 | if (enabled (Level.Trace)) |
|---|
| … | … | |
| 649 | 590 | ***********************************************************************/ |
|---|
| 650 | 591 | |
|---|
| 651 | | final Logger info (lazy char[] msg) |
|---|
| 652 | | { |
|---|
| 653 | | return append (Level.Info, msg); |
|---|
| | 592 | final Logger info (char[] fmt, ...) |
|---|
| | 593 | { |
|---|
| | 594 | return format (Level.Info, fmt, _arguments, _argptr); |
|---|
| 654 | 595 | } |
|---|
| 655 | 596 | |
|---|
| … | … | |
| 660 | 601 | ***********************************************************************/ |
|---|
| 661 | 602 | |
|---|
| 662 | | final void info (lazy void dg) |
|---|
| | 603 | private void info (lazy void dg) |
|---|
| 663 | 604 | { |
|---|
| 664 | 605 | if (enabled (Level.Info)) |
|---|
| … | … | |
| 672 | 613 | ***********************************************************************/ |
|---|
| 673 | 614 | |
|---|
| 674 | | final Logger warn (lazy char[] msg) |
|---|
| 675 | | { |
|---|
| 676 | | return append (Level.Warn, msg); |
|---|
| | 615 | final Logger warn (char[] fmt, ...) |
|---|
| | 616 | { |
|---|
| | 617 | return format (Level.Warn, fmt, _arguments, _argptr); |
|---|
| 677 | 618 | } |
|---|
| 678 | 619 | |
|---|
| … | … | |
| 683 | 624 | ***********************************************************************/ |
|---|
| 684 | 625 | |
|---|
| 685 | | final void warn (lazy void dg) |
|---|
| | 626 | private void warn (lazy void dg) |
|---|
| 686 | 627 | { |
|---|
| 687 | 628 | if (enabled (Level.Warn)) |
|---|
| … | … | |
| 695 | 636 | ***********************************************************************/ |
|---|
| 696 | 637 | |
|---|
| 697 | | final Logger error (lazy char[] msg) |
|---|
| 698 | | { |
|---|
| 699 | | return append (Level.Error, msg); |
|---|
| | 638 | final Logger error (char[] fmt, ...) |
|---|
| | 639 | { |
|---|
| | 640 | return format (Level.Error, fmt, _arguments, _argptr); |
|---|
| 700 | 641 | } |
|---|
| 701 | 642 | |
|---|
| … | … | |
| 706 | 647 | ***********************************************************************/ |
|---|
| 707 | 648 | |
|---|
| 708 | | final void error (lazy void dg) |
|---|
| | 649 | private void error (lazy void dg) |
|---|
| 709 | 650 | { |
|---|
| 710 | 651 | if (enabled (Level.Error)) |
|---|
| … | … | |
| 718 | 659 | ***********************************************************************/ |
|---|
| 719 | 660 | |
|---|
| 720 | | final Logger fatal (lazy char[] msg) |
|---|
| 721 | | { |
|---|
| 722 | | return append (Level.Fatal, msg); |
|---|
| | 661 | final Logger fatal (char[] fmt, ...) |
|---|
| | 662 | { |
|---|
| | 663 | return format (Level.Fatal, fmt, _arguments, _argptr); |
|---|
| 723 | 664 | } |
|---|
| 724 | 665 | |
|---|
| … | … | |
| 729 | 670 | ***********************************************************************/ |
|---|
| 730 | 671 | |
|---|
| 731 | | final void fatal (lazy void dg) |
|---|
| | 672 | private void fatal (lazy void dg) |
|---|
| 732 | 673 | { |
|---|
| 733 | 674 | if (enabled (Level.Fatal)) |
|---|
| … | … | |
| 912 | 853 | final char[] format (char[] buffer, char[] formatStr, ...) |
|---|
| 913 | 854 | { |
|---|
| 914 | | return format (_arguments, _argptr, formatStr, buffer); |
|---|
| | 855 | return Format.vprint (buffer, formatStr, _arguments, _argptr); |
|---|
| 915 | 856 | } |
|---|
| 916 | 857 | |
|---|
| … | … | |
| 922 | 863 | ***********************************************************************/ |
|---|
| 923 | 864 | |
|---|
| 924 | | final char[] format (TypeInfo[] arguments, ArgList argptr, char[] formatStr, char[] scratchpad) |
|---|
| | 865 | final Logger format (Level level, char[] fmt, TypeInfo[] types, ArgList args) |
|---|
| 925 | 866 | { |
|---|
| 926 | | return Format.vprint (scratchpad, formatStr, arguments, argptr); |
|---|
| | 867 | char[2048] tmp = void; |
|---|
| | 868 | |
|---|
| | 869 | if (types.length) |
|---|
| | 870 | append (level, Format.vprint (tmp, fmt, types, args)); |
|---|
| | 871 | else |
|---|
| | 872 | append (level, fmt); |
|---|
| | 873 | return this; |
|---|
| 927 | 874 | } |
|---|
| 928 | 875 | |
|---|
| … | … | |
| 1739 | 1686 | Log.config (Cerr.stream); |
|---|
| 1740 | 1687 | auto log = Log.lookup ("fu.bar"); |
|---|
| 1741 | | log.level = log.level.Info; |
|---|
| | 1688 | log.level = log.level.Trace; |
|---|
| 1742 | 1689 | // traditional usage |
|---|
| 1743 | | log.trace ("hello"); |
|---|
| | 1690 | log.trace ("hello {}", "world"); |
|---|
| 1744 | 1691 | |
|---|
| 1745 | 1692 | // formatted output |
|---|
| | 1693 | /* / |
|---|
| 1746 | 1694 | auto format = Log.format; |
|---|
| 1747 | 1695 | log.info (format ("blah{}", 1)); |
|---|
| … | … | |
| 1751 | 1699 | snap.format ("arg{}; ", 1); |
|---|
| 1752 | 1700 | snap.format ("arg{}; ", 2); |
|---|
| 1753 | | log.trace (snap.format ("error! arg{}", 3)); |
|---|
| | 1701 | //log.trace (snap.format ("error! arg{}", 3)); |
|---|
| 1754 | 1702 | snap.flush; |
|---|
| | 1703 | */ |
|---|
| 1755 | 1704 | } |
|---|
| 1756 | 1705 | } |
|---|
| r3485 |
r3616 |
|
| 35 | 35 | ***********************************************************************/ |
|---|
| 36 | 36 | |
|---|
| 37 | | ILogger trace (lazy char[] msg); |
|---|
| | 37 | ILogger trace (char[] fmt, ...); |
|---|
| 38 | 38 | |
|---|
| 39 | 39 | /*********************************************************************** |
|---|
| … | … | |
| 43 | 43 | ***********************************************************************/ |
|---|
| 44 | 44 | |
|---|
| 45 | | void trace (lazy void dg); |
|---|
| | 45 | //void trace (lazy void dg); |
|---|
| 46 | 46 | |
|---|
| 47 | 47 | /*********************************************************************** |
|---|
| … | … | |
| 51 | 51 | ***********************************************************************/ |
|---|
| 52 | 52 | |
|---|
| 53 | | ILogger info (lazy char[] msg); |
|---|
| | 53 | ILogger info (char[] fmt, ...); |
|---|
| 54 | 54 | |
|---|
| 55 | 55 | /*********************************************************************** |
|---|
| … | … | |
| 59 | 59 | ***********************************************************************/ |
|---|
| 60 | 60 | |
|---|
| 61 | | void info (lazy void dg); |
|---|
| | 61 | //void info (lazy void dg); |
|---|
| 62 | 62 | |
|---|
| 63 | 63 | /*********************************************************************** |
|---|
| … | … | |
| 67 | 67 | ***********************************************************************/ |
|---|
| 68 | 68 | |
|---|
| 69 | | ILogger warn (lazy char[] msg); |
|---|
| | 69 | ILogger warn (char[] fmt, ...); |
|---|
| 70 | 70 | |
|---|
| 71 | 71 | /*********************************************************************** |
|---|
| … | … | |
| 75 | 75 | ***********************************************************************/ |
|---|
| 76 | 76 | |
|---|
| 77 | | void warn (lazy void dg); |
|---|
| | 77 | //void warn (lazy void dg); |
|---|
| 78 | 78 | |
|---|
| 79 | 79 | /*********************************************************************** |
|---|
| … | … | |
| 83 | 83 | ***********************************************************************/ |
|---|
| 84 | 84 | |
|---|
| 85 | | ILogger error (lazy char[] msg); |
|---|
| | 85 | ILogger error (char[] fmt, ...); |
|---|
| 86 | 86 | |
|---|
| 87 | 87 | /*********************************************************************** |
|---|
| … | … | |
| 91 | 91 | ***********************************************************************/ |
|---|
| 92 | 92 | |
|---|
| 93 | | void error (lazy void dg); |
|---|
| | 93 | //void error (lazy void dg); |
|---|
| 94 | 94 | |
|---|
| 95 | 95 | /*********************************************************************** |
|---|
| … | … | |
| 99 | 99 | ***********************************************************************/ |
|---|
| 100 | 100 | |
|---|
| 101 | | ILogger fatal (lazy char[] msg); |
|---|
| | 101 | ILogger fatal (char[] fmt, ...); |
|---|
| 102 | 102 | |
|---|
| 103 | 103 | /*********************************************************************** |
|---|
| … | … | |
| 107 | 107 | ***********************************************************************/ |
|---|
| 108 | 108 | |
|---|
| 109 | | void fatal (lazy void dg); |
|---|
| | 109 | //void fatal (lazy void dg); |
|---|
| 110 | 110 | |
|---|
| 111 | 111 | /*********************************************************************** |
|---|
Download in other formats:
|
 |