在docker容器的日志中查找特定字符串的最佳方法是什么.假设我想查看所有请求,这些请求是在"nginx"docker镜像中创建的,该镜像来自以"127"开头的ip.
grep将无法按预期在docker logs命令上工作:
docker logs nginx | grep "127."
Run Code Online (Sandbox Code Playgroud)
打印所有日志,但不过滤结果!
我正在尝试使用新的Unity UI(2014)构建列表视图.垂直和可滚动列表应包含图像按钮,这些按钮应根据其指定的图像保留其纵横比!所有按钮都应拉伸到屏幕宽度.按钮不应与下一个按钮有间隙.(非常像iOS中的UITableView)

我发现新UI附带的VerticalLayoutGroup对我没有帮助,因为它不能很好地嵌入ScrollRect中.我认为它需要根据包含的项目进行调整,以使其与ScrollRect一起使用.
另一个问题是我无法让按钮保持其宽高比,我通过编写一个小脚本解决了这个问题(见下文).
为了实际完成所需的列表效果,我创建了一个带有ScrollRect的Canvas,然后包含一个用于我的自定义ListLayout脚本的RectTransform.RectTransforms的子节点是按钮.
结构如下所示:

列表中的每个项都会获得一个keep aspect脚本,如下所示:
public class KeepAspect : MonoBehaviour {
public Sprite sprite;
public float aspect = 1;
void Start() {
if (sprite != null) {
aspect = sprite.bounds.size.x / sprite.bounds.size.y;
}
}
void Update() {
RectTransform rectTransform = GetComponent<RectTransform>();
Rect rect = rectTransform.rect;
rectTransform.sizeDelta = new Vector2(rect.width, rect.width * (1f / aspect));
}
}
Run Code Online (Sandbox Code Playgroud)
我的自定义ListLayout脚本,根据包含的项目计算其高度:
public class ListLayout : MonoBehaviour {
public enum Direction { Vertical, Horizontal }
public Direction direction = Direction.Vertical;
public float …Run Code Online (Sandbox Code Playgroud) 我的目标是使用我的功能从 Unity3D 引擎扩展 MonoBehaviour 对象。这就是我所做的:
public static class Extensions {
public static T GetComponentInChildren<T>(this UnityEngine.MonoBehaviour o, bool includeInactive) {
T[] components = o.GetComponentsInChildren<T>(includeInactive);
return components.Length > 0 ? components[0] : default(T);
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我要使用它时,我只能this在调用前面使用时才能访问它:this.GetComponentInChildren(true)但this应该是隐式的,对吧?
所以我认为我做错了什么......
这是我使用扩展的地方:
public class SomeController : MonoBehaviour {
private SomeComponent component;
void Awake() {
component = this.GetComponentInChildren<SomeComponent>(true);
}
}
Run Code Online (Sandbox Code Playgroud)
我希望我清楚了我的问题。有没有办法正确扩展 MonoBehaviour(不需要this显式使用关键字)或者为什么会这样?