Logger
struct Logger
Methods
new
pub fn new(writer: Write, max_level: Level = Level.Info, format: Format = Format.Default): Logger
[src]
pub fn new(writer: Write, max_level: Level = Level.Info, format: Format = Format.Default): Logger {
return Logger {
inner: _Logger
.new(
_create_native_write(writer),
max_level: max_level._as_inner(),
format: format as int
),
};
}
Create a new logger that writes to the given output.
new
pub fn new(writer: Write, max_level: Level = Level.Info, format: Format = Format.Default): Logger
[src]
pub fn new(writer: Write, max_level: Level = Level.Info, format: Format = Format.Default): Logger {
return Logger {
inner: _Logger
.new(
_create_native_write(writer),
max_level: max_level._as_inner(),
format: format as int
),
};
}
Create a new logger that writes to the given output.
Create a new logger that writes to the given output.
Options
max_level
: The maximum log level to output. Defaults toLevel.Info
.format
: The log output format. Defaults toFormat.Default
.
Examples
nv,
use std.io;
use std.log.{Logger, Level};
let logger = Logger.new(io.stdout(), max_level: Level.Debug);
logger.info("Hello, world!");
[src]
pub fn prefix(self, prefix: string): Logger {
return Logger { inner: self.inner, prefix_: prefix };
}
Create a new logger with the given tag.
[src]
pub fn prefix(self, prefix: string): Logger {
return Logger { inner: self.inner, prefix_: prefix };
}
Create a new logger with the given tag.
Create a new logger with the given tag.
This will prefix all log messages with the given tag.
nv,
use std.io;
use std.log.{Logger, Level};
let logger = Logger.new(io.stdout(), max_level: Level.Debug).prefix("myapp: ");
logger.info("Hello, world!");
// Output: "myapp: Hello, world!"
[src]
fn log(self, level: Level, args: ..ToString?) {
let msg_buf = StringBuffer.new();
if (let prefix = self.prefix_) {
msg_buf.push_string(prefix);
}
let first = true;
for (let arg in args) {
if (first) {
first = false;
} else {
msg_buf.push_string(" ");
}
msg_buf.push_string(arg?.to_string() || "<nil>");
}
self.inner.log(level as int, msg_buf.to_string());
}
[src]
fn log(self, level: Level, args: ..ToString?) {
let msg_buf = StringBuffer.new();
if (let prefix = self.prefix_) {
msg_buf.push_string(prefix);
}
let first = true;
for (let arg in args) {
if (first) {
first = false;
} else {
msg_buf.push_string(" ");
}
msg_buf.push_string(arg?.to_string() || "<nil>");
}
self.inner.log(level as int, msg_buf.to_string());
}
[src]
pub fn error(self, args: ..ToString?) {
self.log(Level.Error, ..args);
}
Log a message at the error level.
[src]
pub fn error(self, args: ..ToString?) {
self.log(Level.Error, ..args);
}
Log a message at the error level.
Log a message at the error level.
[src]
pub fn warn(self, args: ..ToString?) {
self.log(Level.Warn, ..args);
}
Log a message at the warn level.
[src]
pub fn warn(self, args: ..ToString?) {
self.log(Level.Warn, ..args);
}
Log a message at the warn level.
Log a message at the warn level.
[src]
pub fn info(self, args: ..ToString?) {
self.log(Level.Info, ..args);
}
Log a message at the info level.
[src]
pub fn info(self, args: ..ToString?) {
self.log(Level.Info, ..args);
}
Log a message at the info level.
Log a message at the info level.
[src]
pub fn debug(self, args: ..ToString?) {
self.log(Level.Debug, ..args);
}
Log a message at the debug level.
[src]
pub fn debug(self, args: ..ToString?) {
self.log(Level.Debug, ..args);
}
Log a message at the debug level.
Log a message at the debug level.