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

master
Delyan Angelov 2022-06-07 12:22:36 +03:00
parent 82d23dedf1
commit a942ecf737
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
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')