0.0.2 • Published 11 years ago

log-timestamp.c v0.0.2

Weekly downloads
14
License
-
Repository
github
Last release
11 years ago

log-timestamp.c

A logger function with the current timestamp prepended

Usage

With dotc

First install this package

npm install log-timestamp.c

Then create a program that requires this function

test.c

#require "log-timestamp.c" as LOG

int main(int argc, char **argv) {
	int i;
	for (i = 0; i < argc; i++)
		LOG("%s\n", argv[i]);
	return 0;
}

Finally compile the program using dotc and execute it

$ dotc test.c
$ ./a.out
[2013-09-23T05:42:03.582Z] ./a.out
[2013-09-23T05:42:03.583Z] testing
[2013-09-23T05:42:03.583Z] this
[2013-09-23T05:42:03.583Z] out

Pure C

Copy log-timestamp.{h,c} to your project, and include the header file as necessary

test.c

#include "log-timestamp.h"
int main(int argc, char **argv) {
	int i;
	for (i = 0; i < argc; i++)
		LOG("%s\n", argv[i]);
	return 0;
}

then compile

$ cc log-timestamp.c test.c

And the program will execute as above

Functions

void LOG(const char *fmt, ...);

License

MIT

0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago