#! /bin/sh -e
## 07_log_to_file_by_default.dpatch by  <weasel@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Change default logging target from stdout to a logfile

if [ $# -lt 1 ]; then
    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
    exit 1
fi

[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"

case "$1" in
    -patch) patch -p1 ${patch_opts} < $0;;
    -unpatch) patch -R -p1 ${patch_opts} < $0;;
    *)
        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
        exit 1;;
esac

exit 0

@DPATCH@
diff -urNad tor~/src/or/config.c tor/src/or/config.c
--- tor~/src/or/config.c	2006-07-24 05:15:02.576170550 +0200
+++ tor/src/or/config.c	2006-07-24 05:18:45.286651501 +0200
@@ -2118,8 +2118,13 @@
     REJECT("Failed to normalize old Log options. See logs for details.");
 
   /* Special case on first boot if no Log options are given. */
-  if (!options->Logs && !options->RunAsDaemon && !from_setconf)
-    config_line_append(&options->Logs, "Log", "notice stdout");
+  if (debian_running_as_debiantor()) {
+    if (!options->Logs && !from_setconf)
+      config_line_append(&options->Logs, "Log", "notice file /var/log/tor/log");
+  } else {
+    if (!options->Logs && !options->RunAsDaemon && !from_setconf)
+      config_line_append(&options->Logs, "Log", "notice stdout");
+  }
 
   if (options_init_logs(options, 1)<0) /* Validate the log(s) */
     REJECT("Failed to validate Log options. See logs for details.");
