v.vcache: support `-d trace_usecache_n` too (less verbose tracing for just the initialisation of CacheManager)

Delyan Angelov 2022-06-07 12:22:36 +03:00 committed by Chewing_Bever
parent 5a5f432588
commit 65dfe199c9
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 10 additions and 0 deletions

View File

@ -39,6 +39,7 @@ pub fn new_cache_manager(opts []string) CacheManager {
if vcache_basepath == '' {
vcache_basepath = os.join_path(os.vmodules_dir(), 'cache')
}
nlog(@FN, 'vcache_basepath: $vcache_basepath | opts:\n $opts')
dlog(@FN, 'vcache_basepath: $vcache_basepath | opts:\n $opts')
if !os.is_dir(vcache_basepath) {
os.mkdir_all(vcache_basepath) or { panic(err) }
@ -125,6 +126,15 @@ pub fn (mut cm CacheManager) load(postfix string, key string) ?string {
[if trace_usecache ?]
pub fn dlog(fname string, s string) {
xlog(fname, s)
}
[if trace_usecache_n ?]
fn nlog(fname string, s string) {
xlog(fname, s)
}
fn xlog(fname string, s string) {
pid := unsafe { mypid() }
if fname[0] != `|` {
eprintln('> VCache | pid: $pid | CacheManager.$fname $s')