Skip to content


Subversion checkout URL

You can clone with
Download ZIP


[RFC] Features/configurable log name #1

wants to merge 2 commits into from

2 participants


So this is a quick and dirty stab at enabling a workflow I need: Two weechats running. One for a work server that likes to do lots of force joining and generally messing with my client, and one for all the other clients.

Before this, I was doing something like;

# Set that up for personal
mv ~/.weechat/weechat.{,personal.}log
# setup for work

but it's pretty awkward. With this patch I can just do

WEECHAT_LOG_NAME=work.log weechat and have it do the right thing. Thoughts?

richo added some commits
@richo richo Respect WEECHAT_LOG_NAME environment variable
This allows running more than one weechat at a time without awkwardly
mv(1)'ing the log files out from under it, or somesuch.
@richo richo Shamelessly add myself to authors fbd1ff4

EDIT: Also, how should I go about emitting a useful warning? Before this patch there was only one real error condition. Should I just refactor log_init and have more than one return value?


Running two different WeeChat with same home can lead to problems (the test is made on weechat.log, but this file is not really a problem).
Bypassing this test will bring problems with config files, log files, and files created by plugins, like scripts, DCC (xfer), ...


By the way, there's a task planned to have separate directories:

@flashcode flashcode closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 3, 2014
  1. @richo

    Respect WEECHAT_LOG_NAME environment variable

    richo authored
    This allows running more than one weechat at a time without awkwardly
    mv(1)'ing the log files out from under it, or somesuch.
  2. @richo
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 2 deletions.
  1. +1 −0  AUTHORS
  2. +17 −2 src/core/wee-log.c
1  AUTHORS
@@ -67,6 +67,7 @@ Alphabetically:
* Quentin Pradet
* Quico Noizeux
* Rettub
+* Richo Healey (richo)
* Rudolf Polzer (divVerent)
* Ryuunosuke Ayanokouzi
* Sergio Durigan Junior
19 src/core/wee-log.c
@@ -29,6 +29,7 @@
#include <string.h>
#include <stdarg.h>
#include <errno.h>
+#include <limits.h>
#include <sys/file.h>
@@ -63,6 +64,7 @@ int
log_open (const char *filename, const char *mode)
int filename_length;
+ char* log_name;
/* exit if log already opened */
if (weechat_log_file)
@@ -72,10 +74,23 @@ log_open (const char *filename, const char *mode)
weechat_log_filename = strdup (filename);
- filename_length = strlen (weechat_home) + 64;
+ log_name = getenv("WEECHAT_LOG_NAME");
+ if (log_name == NULL) {
+ log_name = WEECHAT_LOG_NAME;
+ }
+ filename_length = strlen (weechat_home) + strlen(log_name);
+ filename_length++; /* slash in path */
+ filename_length++; /* NULL terminator */
+ if (filename_length > PATH_MAX) {
+ // XXX emit useful warning?
+ return 0;
+ }
weechat_log_filename = malloc (filename_length);
snprintf (weechat_log_filename, filename_length,
- "%s/%s", weechat_home, WEECHAT_LOG_NAME);
+ "%s/%s", weechat_home, log_name);
weechat_log_file = fopen (weechat_log_filename, mode);
Something went wrong with that request. Please try again.