Implementing std.log

so so at so.com
Thu Apr 21 09:53:17 PDT 2011


>> So you want the iostream way, global logger objects, otherwise i don't  
>> see how this solves the problem you are suggesting.
>
> No globals, of course, loggers are part of objects. In most cases,  
> everyone who adds log entry creates its own logger and add it into a  
> hierarchy.

class A {
	logger log;
}

class B {
	A a;
	logger log;
}

void some_function() {
	auto log = new logger("where to? why would i care who call this? why do i  
need this line anyways? :)")
	log.error(...);
}

---

I think we are looking this from fairly different angles.
Most of the times all i want to do just :

module logger;

void note(uint level, A...)(A a);
void note_redirect(uint level, string);
void note_enable(uint level, bool on);
uint note_new(string);

// default levels
enum {
	warning	= 0,
	error,
	fatal,
}

import logger;

void some_function() {
	...
	note(...);
	...
	note!error(...);
	...
	note!fatal(...);
	...
	note!my_level(...);
}


More information about the Digitalmars-d mailing list