Skip to content

Commit 69dca77

Browse files
committed
Disable default file logging.
Logs now are only displayed in console and a new parameter is used for redirecting logs to a file.
1 parent 420b230 commit 69dca77

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ Every namespace has it own configuration dir in $SODA_USER_HOME/config/NAMESPACE
165165

166166
You can configure **soda** namespace through a **$SODA_USER_HOME/conf/soda/soda.conf** file (or any other name but inside that directory). The supported properties are:
167167

168-
* **LOG_FILE** - The log file (defaults to *$SODA_HOME/log/soda.log*)
169168
* **SODA_NAMESPACE_DELIMITER** - The namespace delimiter (defaults to **.**). Changing this also affects the bash completion
170169
* **SODA_TASK_BASH_COMPLETION_SUFFIX** - The suffix to build the function for custom bash completion (defaults to *_bash_completion*)
171170
* **SODA_FILE_LOG_PATTERN** - The pattern to format logs that goes in *LOG_FILE*
@@ -191,6 +190,8 @@ To log something, just call the **log** function passing the category and messag
191190
* **log_error** - uses the ERROR category
192191
* **log_fatal** - uses the FATAL category
193192

193+
Log messages are shown in console, if you need to persist them, pass the parameter `--log-file=/path/to/the/file`. To disable the console log, pass the parameter `--no-console-log`.
194+
194195
### Custom logging
195196

196197
If you want to use another log system (a *syslog* or another) just define a **log** function.

config/soda/descriptions.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323

2424
SODA_DESCRIPTION_NO_COLORS="Do not use colors"
25-
SODA_DESCRIPTION_NO_FILE_LOG="Do not log in file"
25+
SODA_DESCRIPTION_LOG_FILE="Sets the log file"
2626
SODA_DESCRIPTION_NO_CONSOLE_LOG="Do not log in console"
2727
SODA_DESCRIPTION_VERBOSE="Set the log level to DEBUG"
2828
SODA_DESCRIPTION_LOG_LEVEL="Set the log level (DEBUG INFO WARN ERROR FATAL NONE)"

config/soda/log.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2222
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323

24-
LOG_FILE=/tmp/soda.log
2524
SODA_DATE_LOG_PATTERN="%F %T"
2625
SODA_FILE_LOG_PATTERN="%s | %-6s | %s\n"
2726
SODA_CONSOLE_LOG_PATTERN="%s | %-6s | %s"

scripts/core.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,5 +336,3 @@ exists() {
336336
return 1
337337
fi
338338
}
339-
340-
[ -z "$LOG_FILE" ] && LOG_FILE=/dev/null

scripts/soda/log.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ log() {
7171
console_log "$category" "$message" "$color"
7272
}
7373

74-
# Put a log message in $LOG_FILE
7574
file_log() {
76-
printf "$SODA_FILE_LOG_PATTERN" "$(date +"${SODA_DATE_LOG_PATTERN}")" "$1" "$2" >> $LOG_FILE
75+
:;
7776
}
7877

7978
# Put a log message in console
@@ -86,12 +85,15 @@ console_log() {
8685
fi
8786
}
8887

89-
parameter "no-file-log" "$SODA_DESCRIPTION_NO_FILE_LOG" && {
90-
file_log() { :; }
91-
} || {
88+
parameter "log-file" "$SODA_DESCRIPTION_FILE_LOG" && {
9289
if ! [[ -f "$LOG_FILE" ]]; then
9390
touch "$LOG_FILE"
9491
fi
92+
93+
# Put a log message in $LOG_FILE
94+
file_log() {
95+
printf "$SODA_FILE_LOG_PATTERN" "$(date +"${SODA_DATE_LOG_PATTERN}")" "$1" "$2" >> $LOG_FILE
96+
}
9597
}
9698

9799
parameter "no-console-log" "$SODA_DESCRIPTION_NO_CONSOLE_LOG" && {

0 commit comments

Comments
 (0)