Contextlog implementation

@mdevaev but it still is a function