Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <syslog.h>
- #include <iostream>
- #include <stdlib.h>
- using namespace std;
- int main(int argc, char *argv[])
- {
- int stuff = 0;
- if (argc != 3 && argc != 4) {
- cout << "Usage: log <priority> <prog> <line>" << endl;
- return -1;
- }
- setlogmask (LOG_UPTO (LOG_DEBUG));
- openlog (argv[2], LOG_CONS | LOG_NDELAY, /*atoi (argv[2]) * 8*/ LOG_LOCAL1);
- if (argc == 4) {
- syslog(atoi(argv[1]), argv[3]); // argv[4]
- } else {
- string line;
- while (getline(cin, line)) {
- syslog(atoi(argv[1]), line.c_str());
- }
- }
- closelog();
- return 0;
- }
- // compile with g++ -o log log.cpp
- // chmod +x log
- // ./log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement