Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bahamas10/log-timestamp.c
A logger function with the current timestamp prepended
https://github.com/bahamas10/log-timestamp.c
Last synced: about 2 months ago
JSON representation
A logger function with the current timestamp prepended
- Host: GitHub
- URL: https://github.com/bahamas10/log-timestamp.c
- Owner: bahamas10
- Created: 2013-09-23T05:45:40.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-10-02T21:29:38.000Z (about 11 years ago)
- Last Synced: 2024-05-08T20:01:31.597Z (8 months ago)
- Language: C
- Size: 125 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
log-timestamp.c
===============A logger function with the current timestamp prepended
Usage
-----### With [dotc](https://github.com/substack/dotc)
First install this package
npm install log-timestamp.c
Then create a program that `require`s this function
`test.c`
``` c
#require "log-timestamp.c" as LOGint 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 testing this 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`
``` 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;
}
```And the program will execute as above
Functions
---------### `void LOG(const char *fmt, ...);`
License
-------MIT