• Modules
    • By category
    • By name
    • Most popular
    • Most downloaded
    • Repository
  • Register
  • Log in
  • Help
    • Start using Ceylon Herd
    • Publish your first module
    • Module publishing guidelines
    • All about Ceylon
    • Keyboard Shortcuts

    • s Focus search module bar
      ? Open this information panel
      j Move selection down
      k Move selection up
      enter Open current selection
Module info
Name
FroMage / ceylon.logging / 1.1.0
Ceylon Logging Platform Module
Category SDK

The Ceylon SDK

Backends JVM JavaScript
Maven coordinates
Compatible Ceylon release JVM: 1.1.0 (outdated)
JavaScript: 1.1.0 (outdated)
Published Oct 8, 2014
Stats Downloads (JVM): 775
Downloads (JS): 229
Source downloads: 795
Description

Defines a platform-neutral API for writing log messages. This module does not actually define any infrastructure for log message output, so the program must register a LogWriter function at startup by calling addLogWriter.

addLogWriter {
    void log(Priority p, Category c, String m, Exception? e) {
        value print = p<=info 
                then process.writeLine 
                else process.writeError;
        print("[``system.milliseconds``] ``p.string`` ``m``");
        if (exists e) {
            printStackTrace(e, print);
        }
    }
};

Log messages are written to a Logger. A canonical Logger instance for a package or module may be obtained by calling logger.

Logger log = logger(`module hello`);

The methods Logger.fatal, Logger.error, Logger.warn, Logger.info, Logger.debug, and Logger.trace write log messages with various priorities.

log.debug("trying to do something");
try {
    doSomething();
}
catch (e) {
    log.error("something bad happened", e);
}

For log messages with interpolated expressions, these methods accept an anonymous function.

log.debug(()=>"trying to do ``something``");
try {
    do(something);
}
catch (e) {
    log.error(()=>"badness happened doing ``something``", e);
}

By default, only log messages with priority at least info are sent to the LogWriter functions. To change the minimum priority, assign to defaultPriority.

defaultPriority = debug;

Alternatively, we can assign an explicit priority to a specific Logger by assigning to Logger.priority.

logger(`module hello`).priority = debug;

For integration with other logging libraries, it is possible to completely replace the logger function with a custom function for producing Loggers.

logger = (Category category)
    => JDKLoggerImpl(JDKLogger.getLogger(category.qualifiedName));
Dependencies
ceylon.collection/1.1.0
Usage
  • Import
 import ceylon.logging "1.1.0";
Module links Members
Imported By
Home
Code repository
Issue tracker
Browse
Download .car
Download .js
Download source archive
Download module documentation
View API documentation

Ceylon Herd v1.24 Copyright 2012-2022 Red Hat. About